You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by kr...@apache.org on 2022/03/01 03:36:55 UTC
[solr] branch branch_9_0 updated: SOLR-14920: Spotless formatting for solrj (#706)
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch branch_9_0
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9_0 by this push:
new 061fc3f SOLR-14920: Spotless formatting for solrj (#706)
061fc3f is described below
commit 061fc3ffafb4ede5849a4740192ffd4f36a3e93e
Author: Kevin Risden <ri...@users.noreply.github.com>
AuthorDate: Mon Feb 28 15:51:32 2022 -0500
SOLR-14920: Spotless formatting for solrj (#706)
* Exclude `solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/` from spotless due to significant changes required
---
gradle/validation/spotless.gradle | 4 +-
.../client/solrj/FastStreamingDocsCallback.java | 25 +-
.../apache/solr/client/solrj/ResponseParser.java | 24 +-
.../apache/solr/client/solrj/RoutedAliasTypes.java | 7 +-
.../org/apache/solr/client/solrj/SolrClient.java | 816 +++----
.../org/apache/solr/client/solrj/SolrQuery.java | 554 ++---
.../org/apache/solr/client/solrj/SolrRequest.java | 85 +-
.../org/apache/solr/client/solrj/SolrResponse.java | 31 +-
.../solr/client/solrj/SolrServerException.java | 11 +-
.../client/solrj/StreamingResponseCallback.java | 6 +-
.../apache/solr/client/solrj/V2RequestSupport.java | 10 +-
.../client/solrj/beans/DocumentObjectBinder.java | 140 +-
.../org/apache/solr/client/solrj/beans/Field.java | 8 +-
.../solr/client/solrj/beans/package-info.java | 8 +-
.../client/solrj/cloud/AlreadyExistsException.java | 5 +-
.../client/solrj/cloud/BadVersionException.java | 4 +-
.../client/solrj/cloud/DelegatingCloudManager.java | 104 +-
.../cloud/DelegatingClusterStateProvider.java | 155 +-
.../client/solrj/cloud/DistribStateManager.java | 57 +-
.../solr/client/solrj/cloud/DistributedQueue.java | 17 +-
.../solrj/cloud/DistributedQueueFactory.java | 4 +-
.../solr/client/solrj/cloud/NodeStateProvider.java | 13 +-
.../solr/client/solrj/cloud/NotEmptyException.java | 5 +-
.../apache/solr/client/solrj/cloud/ShardTerms.java | 44 +-
.../solr/client/solrj/cloud/SocketProxy.java | 55 +-
.../solr/client/solrj/cloud/SolrCloudManager.java | 18 +-
.../solr/client/solrj/cloud/VersionedData.java | 14 +-
.../solr/client/solrj/cloud/package-info.java | 6 +-
.../solr/client/solrj/embedded/SSLConfig.java | 94 +-
.../client/solrj/impl/BaseCloudSolrClient.java | 609 ++---
.../solrj/impl/BaseHttpClusterStateProvider.java | 181 +-
.../solr/client/solrj/impl/BaseHttpSolrClient.java | 24 +-
.../client/solrj/impl/BinaryRequestWriter.java | 11 +-
.../client/solrj/impl/BinaryResponseParser.java | 15 +-
.../client/solrj/impl/CloudHttp2SolrClient.java | 111 +-
.../solr/client/solrj/impl/CloudSolrClient.java | 167 +-
.../client/solrj/impl/ClusterStateProvider.java | 58 +-
.../impl/ConcurrentUpdateHttp2SolrClient.java | 193 +-
.../solrj/impl/ConcurrentUpdateSolrClient.java | 523 +++--
.../solrj/impl/DelegationTokenHttpSolrClient.java | 21 +-
.../solrj/impl/Http2ClusterStateProvider.java | 6 +-
.../solr/client/solrj/impl/Http2SolrClient.java | 390 ++--
.../solrj/impl/HttpClientBuilderFactory.java | 19 +-
.../solr/client/solrj/impl/HttpClientUtil.java | 328 +--
.../solrj/impl/HttpClusterStateProvider.java | 7 +-
.../client/solrj/impl/HttpListenerFactory.java | 17 +-
.../solr/client/solrj/impl/HttpSolrClient.java | 595 ++---
.../solrj/impl/InputStreamResponseParser.java | 7 +-
.../client/solrj/impl/Krb5HttpClientBuilder.java | 155 +-
.../solr/client/solrj/impl/LBHttp2SolrClient.java | 256 ++-
.../solr/client/solrj/impl/LBHttpSolrClient.java | 166 +-
.../solr/client/solrj/impl/LBSolrClient.java | 178 +-
.../solr/client/solrj/impl/NoOpResponseParser.java | 16 +-
.../solr/client/solrj/impl/PreemptiveAuth.java | 19 +-
.../PreemptiveBasicAuthClientBuilderFactory.java | 88 +-
.../solr/client/solrj/impl/SolrClientBuilder.java | 36 +-
.../client/solrj/impl/SolrClientCloudManager.java | 28 +-
.../solrj/impl/SolrClientNodeStateProvider.java | 234 +-
.../client/solrj/impl/SolrHttpClientBuilder.java | 20 +-
.../solrj/impl/SolrHttpClientContextBuilder.java | 25 +-
.../solrj/impl/SolrHttpRequestRetryHandler.java | 91 +-
.../solrj/impl/SolrPortAwareCookieSpecFactory.java | 12 +-
.../solrj/impl/StreamingBinaryResponseParser.java | 175 +-
.../solr/client/solrj/impl/XMLResponseParser.java | 648 +++---
.../solrj/impl/ZkClientClusterStateProvider.java | 40 +-
.../client/solrj/impl/ZkDistribStateManager.java | 47 +-
.../solr/client/solrj/impl/package-info.java | 7 +-
.../client/solrj/io/ClassificationEvaluation.java | 11 +-
.../java/org/apache/solr/client/solrj/io/Lang.java | 67 +-
.../apache/solr/client/solrj/io/ModelCache.java | 41 +-
.../solr/client/solrj/io/SolrClientCache.java | 47 +-
.../org/apache/solr/client/solrj/io/Tuple.java | 130 +-
.../client/solrj/io/comp/ComparatorLambda.java | 5 +-
.../solr/client/solrj/io/comp/ComparatorOrder.java | 22 +-
.../solr/client/solrj/io/comp/FieldComparator.java | 171 +-
.../apache/solr/client/solrj/io/comp/HashKey.java | 18 +-
.../solrj/io/comp/MultipleFieldComparator.java | 96 +-
.../solrj/io/comp/SingleValueComparator.java | 29 +-
.../client/solrj/io/comp/StreamComparator.java | 7 +-
.../solr/client/solrj/io/comp/package-info.java | 8 +-
.../apache/solr/client/solrj/io/eq/Equalitor.java | 10 +-
.../solr/client/solrj/io/eq/FieldEqualitor.java | 109 +-
.../client/solrj/io/eq/MultipleFieldEqualitor.java | 94 +-
.../solr/client/solrj/io/eq/StreamEqualitor.java | 4 +-
.../solr/client/solrj/io/eq/package-info.java | 6 +-
.../solrj/io/eval/AbsoluteValueEvaluator.java | 32 +-
.../solr/client/solrj/io/eval/AddEvaluator.java | 56 +-
.../solr/client/solrj/io/eval/AkimaEvaluator.java | 22 +-
.../solr/client/solrj/io/eval/AndEvaluator.java | 45 +-
.../solr/client/solrj/io/eval/AnovaEvaluator.java | 36 +-
.../solr/client/solrj/io/eval/AppendEvaluator.java | 23 +-
.../client/solrj/io/eval/ArcCosineEvaluator.java | 31 +-
.../client/solrj/io/eval/ArcSineEvaluator.java | 31 +-
.../client/solrj/io/eval/ArcTangentEvaluator.java | 32 +-
.../solr/client/solrj/io/eval/ArrayEvaluator.java | 63 +-
.../solr/client/solrj/io/eval/AscEvaluator.java | 64 +-
.../solr/client/solrj/io/eval/Attributes.java | 5 +-
.../solrj/io/eval/BetaDistributionEvaluator.java | 28 +-
.../solrj/io/eval/BicubicSplineEvaluator.java | 22 +-
.../io/eval/BinomialCoefficientEvaluator.java | 29 +-
.../io/eval/BinomialDistributionEvaluator.java | 31 +-
.../client/solrj/io/eval/CanberraEvaluator.java | 9 +-
.../client/solrj/io/eval/CeilingEvaluator.java | 31 +-
.../solrj/io/eval/ChebyshevDistanceEvaluator.java | 50 +-
.../client/solrj/io/eval/ChebyshevEvaluator.java | 9 +-
.../solrj/io/eval/ChiSquareDataSetEvaluator.java | 15 +-
.../client/solrj/io/eval/CoalesceEvaluator.java | 22 +-
.../client/solrj/io/eval/ColumnAtEvaluator.java | 21 +-
.../client/solrj/io/eval/ColumnCountEvaluator.java | 17 +-
.../solr/client/solrj/io/eval/ColumnEvaluator.java | 55 +-
.../solr/client/solrj/io/eval/ConcatEvaluator.java | 28 +-
.../io/eval/ConstantDistributionEvaluator.java | 21 +-
.../client/solrj/io/eval/ConversionEvaluator.java | 135 +-
.../client/solrj/io/eval/ConvexHullEvaluator.java | 17 +-
.../client/solrj/io/eval/ConvolutionEvaluator.java | 54 +-
.../solr/client/solrj/io/eval/CopyOfEvaluator.java | 59 +-
.../client/solrj/io/eval/CopyOfRangeEvaluator.java | 101 +-
.../client/solrj/io/eval/CorrelationEvaluator.java | 94 +-
.../io/eval/CorrelationSignificanceEvaluator.java | 32 +-
.../solrj/io/eval/CosineDistanceEvaluator.java | 12 +-
.../solr/client/solrj/io/eval/CosineEvaluator.java | 31 +-
.../solrj/io/eval/CosineSimilarityEvaluator.java | 47 +-
.../client/solrj/io/eval/CovarianceEvaluator.java | 22 +-
.../client/solrj/io/eval/CubedRootEvaluator.java | 31 +-
.../io/eval/CumulativeProbabilityEvaluator.java | 49 +-
.../solr/client/solrj/io/eval/DateEvaluator.java | 24 +-
.../solr/client/solrj/io/eval/DbscanEvaluator.java | 40 +-
.../client/solrj/io/eval/DensityEvaluator.java | 26 +-
.../client/solrj/io/eval/DerivativeEvaluator.java | 25 +-
.../client/solrj/io/eval/DescribeEvaluator.java | 38 +-
.../client/solrj/io/eval/DistanceEvaluator.java | 103 +-
.../solr/client/solrj/io/eval/DivideEvaluator.java | 75 +-
.../client/solrj/io/eval/DotProductEvaluator.java | 54 +-
.../solr/client/solrj/io/eval/DoubleEvaluator.java | 27 +-
.../solr/client/solrj/io/eval/EBEAddEvaluator.java | 40 +-
.../client/solrj/io/eval/EBEDivideEvaluator.java | 51 +-
.../client/solrj/io/eval/EBEMultiplyEvaluator.java | 52 +-
.../client/solrj/io/eval/EBESubtractEvaluator.java | 39 +-
.../client/solrj/io/eval/EarthMoversEvaluator.java | 10 +-
.../io/eval/EmpiricalDistributionEvaluator.java | 42 +-
.../solrj/io/eval/EnclosingDiskEvaluator.java | 23 +-
.../io/eval/EnumeratedDistributionEvaluator.java | 37 +-
.../client/solrj/io/eval/EqualToEvaluator.java | 48 +-
.../solrj/io/eval/EuclideanDistanceEvaluator.java | 52 +-
.../client/solrj/io/eval/EuclideanEvaluator.java | 9 +-
.../client/solrj/io/eval/EvaluatorException.java | 2 +-
.../client/solrj/io/eval/ExclusiveOrEvaluator.java | 66 +-
.../io/eval/ExponentialMovingAverageEvaluator.java | 103 +-
.../solr/client/solrj/io/eval/FFTEvaluator.java | 26 +-
.../client/solrj/io/eval/FactorialEvaluator.java | 28 +-
.../solrj/io/eval/FeatureSelectEvaluator.java | 40 +-
.../client/solrj/io/eval/FieldValueEvaluator.java | 44 +-
.../client/solrj/io/eval/FindDelayEvaluator.java | 65 +-
.../solr/client/solrj/io/eval/FloorEvaluator.java | 31 +-
.../solrj/io/eval/FrequencyTableEvaluator.java | 39 +-
.../client/solrj/io/eval/FuzzyKmeansEvaluator.java | 43 +-
.../solrj/io/eval/GTestDataSetEvaluator.java | 13 +-
.../solrj/io/eval/GammaDistributionEvaluator.java | 31 +-
.../client/solrj/io/eval/GaussFitEvaluator.java | 32 +-
.../io/eval/GeometricDistributionEvaluator.java | 21 +-
.../solrj/io/eval/GetAmplitudeEvaluator.java | 17 +-
.../io/eval/GetAngularFrequencyEvaluator.java | 20 +-
.../client/solrj/io/eval/GetAreaEvaluator.java | 14 +-
.../solrj/io/eval/GetAttributeEvaluator.java | 19 +-
.../solrj/io/eval/GetAttributesEvaluator.java | 17 +-
.../solrj/io/eval/GetBaryCenterEvaluator.java | 23 +-
.../solrj/io/eval/GetBoundarySizeEvaluator.java | 17 +-
.../client/solrj/io/eval/GetCacheEvaluator.java | 22 +-
.../client/solrj/io/eval/GetCenterEvaluator.java | 20 +-
.../solrj/io/eval/GetCentroidsEvaluator.java | 22 +-
.../client/solrj/io/eval/GetClusterEvaluator.java | 26 +-
.../solrj/io/eval/GetColumnLabelsEvaluator.java | 17 +-
.../io/eval/GetMembershipMatrixEvaluator.java | 20 +-
.../client/solrj/io/eval/GetPhaseEvaluator.java | 14 +-
.../client/solrj/io/eval/GetRadiusEvaluator.java | 15 +-
.../solrj/io/eval/GetRowLabelsEvaluator.java | 17 +-
.../solrj/io/eval/GetSupportPointsEvaluator.java | 26 +-
.../client/solrj/io/eval/GetValueEvaluator.java | 21 +-
.../client/solrj/io/eval/GetVerticesEvaluator.java | 21 +-
.../client/solrj/io/eval/GrandSumEvaluator.java | 20 +-
.../solrj/io/eval/GreaterThanEqualToEvaluator.java | 54 +-
.../client/solrj/io/eval/GreaterThanEvaluator.java | 51 +-
.../client/solrj/io/eval/HarmonicFitEvaluator.java | 39 +-
.../client/solrj/io/eval/HistogramEvaluator.java | 66 +-
.../solrj/io/eval/HyperbolicCosineEvaluator.java | 32 +-
.../solrj/io/eval/HyperbolicSineEvaluator.java | 32 +-
.../solrj/io/eval/HyperbolicTangentEvaluator.java | 35 +-
.../solr/client/solrj/io/eval/IFFTEvaluator.java | 24 +-
.../client/solrj/io/eval/IfThenElseEvaluator.java | 40 +-
.../client/solrj/io/eval/IndexOfEvaluator.java | 22 +-
.../client/solrj/io/eval/IntegrateEvaluator.java | 22 +-
.../solr/client/solrj/io/eval/IsNullEvaluator.java | 22 +-
.../solr/client/solrj/io/eval/KmeansEvaluator.java | 44 +-
.../solr/client/solrj/io/eval/KnnEvaluator.java | 46 +-
.../solrj/io/eval/KnnRegressionEvaluator.java | 143 +-
.../solrj/io/eval/KolmogorovSmirnovEvaluator.java | 68 +-
.../solr/client/solrj/io/eval/L1NormEvaluator.java | 37 +-
.../client/solrj/io/eval/LInfNormEvaluator.java | 37 +-
.../solrj/io/eval/LatLonVectorsEvaluator.java | 48 +-
.../client/solrj/io/eval/LeftShiftEvaluator.java | 15 +-
.../solr/client/solrj/io/eval/LengthEvaluator.java | 43 +-
.../solr/client/solrj/io/eval/LerpEvaluator.java | 22 +-
.../solrj/io/eval/LessThanEqualToEvaluator.java | 51 +-
.../client/solrj/io/eval/LessThanEvaluator.java | 50 +-
.../client/solrj/io/eval/ListCacheEvaluator.java | 26 +-
.../solr/client/solrj/io/eval/LoessEvaluator.java | 33 +-
.../solr/client/solrj/io/eval/Log10Evaluator.java | 27 +-
.../io/eval/LogNormalDistributionEvaluator.java | 31 +-
.../solr/client/solrj/io/eval/LongEvaluator.java | 27 +-
.../solr/client/solrj/io/eval/LowerEvaluator.java | 25 +-
.../client/solrj/io/eval/ManhattanEvaluator.java | 9 +-
.../solrj/io/eval/MannWhitneyUEvaluator.java | 41 +-
.../solr/client/solrj/io/eval/ManyValueWorker.java | 3 +-
.../client/solrj/io/eval/MarkovChainEvaluator.java | 32 +-
.../client/solrj/io/eval/MatchesEvaluator.java | 18 +-
.../apache/solr/client/solrj/io/eval/Matrix.java | 11 +-
.../solr/client/solrj/io/eval/MatrixEvaluator.java | 19 +-
.../solrj/io/eval/MatrixMultiplyEvaluator.java | 35 +-
.../solrj/io/eval/MeanDifferenceEvaluator.java | 43 +-
.../solr/client/solrj/io/eval/MeanEvaluator.java | 39 +-
.../solr/client/solrj/io/eval/MemsetEvaluator.java | 88 +-
.../client/solrj/io/eval/MinMaxScaleEvaluator.java | 30 +-
.../solr/client/solrj/io/eval/ModeEvaluator.java | 42 +-
.../solr/client/solrj/io/eval/ModuloEvaluator.java | 77 +-
.../client/solrj/io/eval/MonteCarloEvaluator.java | 45 +-
.../solrj/io/eval/MovingAverageEvaluator.java | 63 +-
.../client/solrj/io/eval/MovingMADEvaluator.java | 56 +-
.../solrj/io/eval/MovingMedianEvaluator.java | 51 +-
.../client/solrj/io/eval/MultiKmeansEvaluator.java | 47 +-
.../MultiVariateNormalDistributionEvaluator.java | 35 +-
.../client/solrj/io/eval/MultiplyEvaluator.java | 56 +-
.../client/solrj/io/eval/NaturalEvaluator.java | 18 +-
.../client/solrj/io/eval/NaturalLogEvaluator.java | 32 +-
.../solr/client/solrj/io/eval/NormEvaluator.java | 37 +-
.../solrj/io/eval/NormalDistributionEvaluator.java | 33 +-
.../client/solrj/io/eval/NormalizeEvaluator.java | 36 +-
.../solrj/io/eval/NormalizeSumEvaluator.java | 41 +-
.../solr/client/solrj/io/eval/NotEvaluator.java | 44 +-
.../client/solrj/io/eval/NotNullEvaluator.java | 22 +-
.../solrj/io/eval/OLSRegressionEvaluator.java | 44 +-
.../solr/client/solrj/io/eval/OneValueWorker.java | 12 +-
.../solr/client/solrj/io/eval/OnesEvaluator.java | 18 +-
.../solr/client/solrj/io/eval/OrEvaluator.java | 45 +-
.../client/solrj/io/eval/OscillateEvaluator.java | 20 +-
.../client/solrj/io/eval/OutliersEvaluator.java | 63 +-
.../client/solrj/io/eval/PairSortEvaluator.java | 69 +-
.../client/solrj/io/eval/PairedTTestEvaluator.java | 21 +-
.../client/solrj/io/eval/PercentileEvaluator.java | 55 +-
.../solr/client/solrj/io/eval/PivotEvaluator.java | 42 +-
.../io/eval/PoissonDistributionEvaluator.java | 21 +-
.../solrj/io/eval/PolyFitDerivativeEvaluator.java | 54 +-
.../client/solrj/io/eval/PolyFitEvaluator.java | 51 +-
.../solr/client/solrj/io/eval/PowerEvaluator.java | 50 +-
.../client/solrj/io/eval/PrecisionEvaluator.java | 37 +-
.../client/solrj/io/eval/PredictEvaluator.java | 78 +-
.../solr/client/solrj/io/eval/PrimesEvaluator.java | 27 +-
.../client/solrj/io/eval/ProbabilityEvaluator.java | 61 +-
.../solrj/io/eval/ProjectToBorderEvaluator.java | 38 +-
.../client/solrj/io/eval/PutCacheEvaluator.java | 29 +-
.../solr/client/solrj/io/eval/RankEvaluator.java | 39 +-
.../client/solrj/io/eval/RawValueEvaluator.java | 66 +-
.../solr/client/solrj/io/eval/RecNumEvaluator.java | 6 +-
.../solr/client/solrj/io/eval/RecipEvaluator.java | 27 +-
.../solrj/io/eval/RecursiveBooleanEvaluator.java | 94 +-
.../client/solrj/io/eval/RecursiveEvaluator.java | 216 +-
.../solrj/io/eval/RecursiveNumericEvaluator.java | 67 +-
.../io/eval/RecursiveNumericListEvaluator.java | 50 +-
.../solrj/io/eval/RecursiveObjectEvaluator.java | 12 +-
.../solrj/io/eval/RecursiveTemporalEvaluator.java | 99 +-
.../client/solrj/io/eval/RegressionEvaluator.java | 68 +-
.../client/solrj/io/eval/RemoveCacheEvaluator.java | 25 +-
.../solr/client/solrj/io/eval/RepeatEvaluator.java | 20 +-
.../client/solrj/io/eval/ReverseEvaluator.java | 34 +-
.../client/solrj/io/eval/RightShiftEvaluator.java | 19 +-
.../solr/client/solrj/io/eval/RoundEvaluator.java | 31 +-
.../solr/client/solrj/io/eval/RowAtEvaluator.java | 21 +-
.../client/solrj/io/eval/RowCountEvaluator.java | 14 +-
.../solr/client/solrj/io/eval/SampleEvaluator.java | 71 +-
.../client/solrj/io/eval/ScalarAddEvaluator.java | 31 +-
.../solrj/io/eval/ScalarDivideEvaluator.java | 15 +-
.../solrj/io/eval/ScalarMultiplyEvaluator.java | 15 +-
.../solrj/io/eval/ScalarSubtractEvaluator.java | 15 +-
.../solr/client/solrj/io/eval/ScaleEvaluator.java | 52 +-
.../client/solrj/io/eval/SequenceEvaluator.java | 42 +-
.../solrj/io/eval/SetColumnLabelsEvaluator.java | 34 +-
.../solrj/io/eval/SetRowLabelsEvaluator.java | 34 +-
.../client/solrj/io/eval/SetValueEvaluator.java | 25 +-
.../solr/client/solrj/io/eval/SineEvaluator.java | 31 +-
.../solr/client/solrj/io/eval/SourceEvaluator.java | 7 +-
.../solr/client/solrj/io/eval/SplineEvaluator.java | 22 +-
.../solr/client/solrj/io/eval/SplitEvaluator.java | 18 +-
.../client/solrj/io/eval/SquareRootEvaluator.java | 32 +-
.../solrj/io/eval/StandardDeviationEvaluator.java | 69 +-
.../solr/client/solrj/io/eval/StreamEvaluator.java | 29 +-
.../solrj/io/eval/StreamEvaluatorException.java | 6 +-
.../client/solrj/io/eval/SubtractEvaluator.java | 74 +-
.../client/solrj/io/eval/SumColumnsEvaluator.java | 29 +-
.../solrj/io/eval/SumDifferenceEvaluator.java | 43 +-
.../client/solrj/io/eval/SumRowsEvaluator.java | 26 +-
.../solr/client/solrj/io/eval/SumSqEvaluator.java | 21 +-
.../solr/client/solrj/io/eval/TTestEvaluator.java | 24 +-
.../client/solrj/io/eval/TangentEvaluator.java | 31 +-
.../client/solrj/io/eval/TemporalEvaluatorDay.java | 11 +-
.../io/eval/TemporalEvaluatorDayOfQuarter.java | 11 +-
.../solrj/io/eval/TemporalEvaluatorDayOfYear.java | 11 +-
.../solrj/io/eval/TemporalEvaluatorEpoch.java | 13 +-
.../solrj/io/eval/TemporalEvaluatorHour.java | 11 +-
.../solrj/io/eval/TemporalEvaluatorMinute.java | 11 +-
.../solrj/io/eval/TemporalEvaluatorMonth.java | 11 +-
.../solrj/io/eval/TemporalEvaluatorQuarter.java | 11 +-
.../solrj/io/eval/TemporalEvaluatorSecond.java | 11 +-
.../solrj/io/eval/TemporalEvaluatorWeek.java | 11 +-
.../solrj/io/eval/TemporalEvaluatorYear.java | 11 +-
.../client/solrj/io/eval/TermVectorsEvaluator.java | 31 +-
.../solrj/io/eval/TimeDifferencingEvaluator.java | 96 +-
.../client/solrj/io/eval/TopFeaturesEvaluator.java | 40 +-
.../client/solrj/io/eval/TransposeEvaluator.java | 23 +-
.../io/eval/TriangularDistributionEvaluator.java | 12 +-
.../solr/client/solrj/io/eval/TrimEvaluator.java | 25 +-
.../solr/client/solrj/io/eval/TruncEvaluator.java | 26 +-
.../solr/client/solrj/io/eval/TwoValueWorker.java | 12 +-
.../io/eval/UniformDistributionEvaluator.java | 33 +-
.../eval/UniformIntegerDistributionEvaluator.java | 31 +-
.../solr/client/solrj/io/eval/UnitEvaluator.java | 40 +-
.../solr/client/solrj/io/eval/UpperEvaluator.java | 25 +-
.../solr/client/solrj/io/eval/UuidEvaluator.java | 18 +-
.../client/solrj/io/eval/ValueAtEvaluator.java | 33 +-
.../solr/client/solrj/io/eval/ValueWorker.java | 3 +-
.../client/solrj/io/eval/VarianceEvaluator.java | 68 +-
.../solr/client/solrj/io/eval/VectorFunction.java | 5 +-
.../io/eval/WeibullDistributionEvaluator.java | 31 +-
.../solr/client/solrj/io/eval/ZerosEvaluator.java | 18 +-
.../solrj/io/eval/ZipFDistributionEvaluator.java | 28 +-
.../solr/client/solrj/io/eval/package-info.java | 4 +-
.../client/solrj/io/graph/GatherNodesStream.java | 466 ++--
.../apache/solr/client/solrj/io/graph/Node.java | 28 +-
.../client/solrj/io/graph/ShortestPathStream.java | 257 ++-
.../solr/client/solrj/io/graph/Traversal.java | 10 +-
.../client/solrj/io/graph/TraversalIterator.java | 23 +-
.../solr/client/solrj/io/graph/package-info.java | 5 +-
.../solr/client/solrj/io/ops/ConcatOperation.java | 53 +-
.../client/solrj/io/ops/DistinctOperation.java | 18 +-
.../solr/client/solrj/io/ops/GroupOperation.java | 65 +-
.../solr/client/solrj/io/ops/ReplaceOperation.java | 84 +-
.../solrj/io/ops/ReplaceWithFieldOperation.java | 101 +-
.../solrj/io/ops/ReplaceWithValueOperation.java | 111 +-
.../solr/client/solrj/io/ops/StreamOperation.java | 5 +-
.../solr/client/solrj/io/ops/package-info.java | 8 +-
.../apache/solr/client/solrj/io/package-info.java | 7 +-
.../solr/client/solrj/io/sql/ConnectionImpl.java | 80 +-
.../client/solrj/io/sql/DatabaseMetaDataImpl.java | 97 +-
.../solr/client/solrj/io/sql/DriverImpl.java | 17 +-
.../client/solrj/io/sql/PreparedStatementImpl.java | 205 +-
.../solr/client/solrj/io/sql/ResultSetImpl.java | 105 +-
.../client/solrj/io/sql/ResultSetMetaDataImpl.java | 9 +-
.../solr/client/solrj/io/sql/StatementImpl.java | 34 +-
.../solr/client/solrj/io/sql/package-info.java | 14 +-
.../solr/client/solrj/io/stream/BiJoinStream.java | 112 +-
.../client/solrj/io/stream/CalculatorStream.java | 35 +-
.../solrj/io/stream/CartesianProductStream.java | 271 ++-
.../solr/client/solrj/io/stream/CellStream.java | 44 +-
.../client/solrj/io/stream/CloudSolrStream.java | 232 +-
.../solr/client/solrj/io/stream/CommitStream.java | 219 +-
.../client/solrj/io/stream/ComplementStream.java | 171 +-
.../solr/client/solrj/io/stream/CsvStream.java | 89 +-
.../solr/client/solrj/io/stream/DaemonStream.java | 137 +-
.../client/solrj/io/stream/DeepRandomStream.java | 185 +-
.../solr/client/solrj/io/stream/DeleteStream.java | 44 +-
.../solr/client/solrj/io/stream/DrillStream.java | 207 +-
.../solr/client/solrj/io/stream/EchoStream.java | 36 +-
.../solr/client/solrj/io/stream/EvalStream.java | 40 +-
.../client/solrj/io/stream/ExceptionStream.java | 19 +-
.../client/solrj/io/stream/ExecutorStream.java | 65 +-
.../solr/client/solrj/io/stream/Facet2DStream.java | 156 +-
.../solr/client/solrj/io/stream/FacetStream.java | 710 +++---
.../solrj/io/stream/FeaturesSelectionStream.java | 194 +-
.../solr/client/solrj/io/stream/FetchStream.java | 136 +-
.../solr/client/solrj/io/stream/GetStream.java | 19 +-
.../client/solrj/io/stream/HashJoinStream.java | 244 +-
.../client/solrj/io/stream/HashRollupStream.java | 117 +-
.../solr/client/solrj/io/stream/HavingStream.java | 79 +-
.../client/solrj/io/stream/InnerJoinStream.java | 40 +-
.../client/solrj/io/stream/IntersectStream.java | 170 +-
.../solr/client/solrj/io/stream/JDBCStream.java | 710 +++---
.../client/solrj/io/stream/JSONTupleStream.java | 55 +-
.../solrj/io/stream/JavabinTupleStreamParser.java | 63 +-
.../solr/client/solrj/io/stream/JoinStream.java | 156 +-
.../solr/client/solrj/io/stream/KnnStream.java | 111 +-
.../solrj/io/stream/LeftOuterJoinStream.java | 39 +-
.../solr/client/solrj/io/stream/LetStream.java | 70 +-
.../solr/client/solrj/io/stream/ListStream.java | 46 +-
.../solr/client/solrj/io/stream/MergeStream.java | 224 +-
.../solr/client/solrj/io/stream/ModelStream.java | 88 +-
.../solr/client/solrj/io/stream/NoOpStream.java | 35 +-
.../solr/client/solrj/io/stream/NullStream.java | 60 +-
.../solrj/io/stream/OuterHashJoinStream.java | 115 +-
.../client/solrj/io/stream/ParallelListStream.java | 40 +-
.../solrj/io/stream/ParallelMetricsRollup.java | 44 +-
.../client/solrj/io/stream/ParallelStream.java | 214 +-
.../solr/client/solrj/io/stream/PlotStream.java | 94 +-
.../client/solrj/io/stream/PriorityStream.java | 63 +-
.../client/solrj/io/stream/PushBackStream.java | 37 +-
.../client/solrj/io/stream/RandomFacadeStream.java | 61 +-
.../solr/client/solrj/io/stream/RandomStream.java | 113 +-
.../solr/client/solrj/io/stream/RankStream.java | 182 +-
.../solr/client/solrj/io/stream/ReducerStream.java | 189 +-
.../solr/client/solrj/io/stream/RollupStream.java | 178 +-
.../client/solrj/io/stream/ScoreNodesStream.java | 108 +-
.../client/solrj/io/stream/SearchFacadeStream.java | 61 +-
.../solr/client/solrj/io/stream/SearchStream.java | 99 +-
.../solr/client/solrj/io/stream/SelectStream.java | 258 ++-
.../solr/client/solrj/io/stream/ShuffleStream.java | 95 +-
.../solrj/io/stream/SignificantTermsStream.java | 212 +-
.../solr/client/solrj/io/stream/SolrStream.java | 108 +-
.../solr/client/solrj/io/stream/SortStream.java | 184 +-
.../solr/client/solrj/io/stream/SqlStream.java | 61 +-
.../solr/client/solrj/io/stream/StatsStream.java | 181 +-
.../solr/client/solrj/io/stream/StreamContext.java | 26 +-
.../client/solrj/io/stream/TextLogitStream.java | 301 ++-
.../client/solrj/io/stream/TimeSeriesStream.java | 340 +--
.../solr/client/solrj/io/stream/TopicStream.java | 267 ++-
.../solr/client/solrj/io/stream/TsvStream.java | 34 +-
.../solr/client/solrj/io/stream/TupStream.java | 124 +-
.../solr/client/solrj/io/stream/TupleStream.java | 144 +-
.../client/solrj/io/stream/TupleStreamParser.java | 3 +-
.../solr/client/solrj/io/stream/UniqueStream.java | 146 +-
.../solr/client/solrj/io/stream/UpdateStream.java | 227 +-
.../solr/client/solrj/io/stream/ZplotStream.java | 154 +-
.../solrj/io/stream/expr/DefaultStreamFactory.java | 1 -
.../client/solrj/io/stream/expr/Explanation.java | 121 +-
.../client/solrj/io/stream/expr/Expressible.java | 15 +-
.../solrj/io/stream/expr/InjectionDefense.java | 60 +-
.../solrj/io/stream/expr/StreamExplanation.java | 44 +-
.../solrj/io/stream/expr/StreamExpression.java | 96 +-
.../expr/StreamExpressionNamedParameter.java | 88 +-
.../io/stream/expr/StreamExpressionParameter.java | 8 +-
.../io/stream/expr/StreamExpressionParser.java | 145 +-
.../io/stream/expr/StreamExpressionValue.java | 46 +-
.../client/solrj/io/stream/expr/StreamFactory.java | 312 ++-
.../client/solrj/io/stream/expr/package-info.java | 10 +-
.../client/solrj/io/stream/metrics/Bucket.java | 7 +-
.../io/stream/metrics/CountDistinctMetric.java | 116 +-
.../solrj/io/stream/metrics/CountMetric.java | 19 +-
.../client/solrj/io/stream/metrics/MaxMetric.java | 53 +-
.../client/solrj/io/stream/metrics/MeanMetric.java | 57 +-
.../client/solrj/io/stream/metrics/Metric.java | 39 +-
.../client/solrj/io/stream/metrics/MinMetric.java | 53 +-
.../solrj/io/stream/metrics/PercentileMetric.java | 33 +-
.../client/solrj/io/stream/metrics/StdMetric.java | 32 +-
.../client/solrj/io/stream/metrics/SumMetric.java | 47 +-
.../solrj/io/stream/metrics/WeightedSumMetric.java | 15 +-
.../solrj/io/stream/metrics/package-info.java | 7 +-
.../solr/client/solrj/io/stream/package-info.java | 10 +-
.../org/apache/solr/client/solrj/package-info.java | 8 +-
.../solrj/request/AbstractUpdateRequest.java | 83 +-
.../solr/client/solrj/request/ApiMapping.java | 79 +-
.../solrj/request/CollectionAdminRequest.java | 1032 +++++----
.../solrj/request/ConfigSetAdminRequest.java | 92 +-
.../solrj/request/ContentStreamUpdateRequest.java | 26 +-
.../client/solrj/request/CoreAdminRequest.java | 403 ++--
.../solr/client/solrj/request/CoreApiMapping.java | 74 +-
.../solr/client/solrj/request/CoreStatus.java | 1 -
.../solrj/request/DelegationTokenRequest.java | 20 +-
.../client/solrj/request/DirectXmlRequest.java | 5 +-
.../solrj/request/DocumentAnalysisRequest.java | 43 +-
.../client/solrj/request/FieldAnalysisRequest.java | 62 +-
.../client/solrj/request/HealthCheckRequest.java | 25 +-
.../solr/client/solrj/request/IsUpdateRequest.java | 8 +-
.../solrj/request/JavaBinUpdateRequestCodec.java | 130 +-
.../solr/client/solrj/request/LukeRequest.java | 75 +-
.../solrj/request/MultiContentWriterRequest.java | 71 +-
.../solr/client/solrj/request/QueryRequest.java | 42 +-
.../solr/client/solrj/request/RequestWriter.java | 31 +-
.../apache/solr/client/solrj/request/SolrPing.java | 53 +-
.../solrj/request/StreamingUpdateRequest.java | 53 +-
.../solr/client/solrj/request/UpdateRequest.java | 213 +-
.../solr/client/solrj/request/V2Request.java | 19 +-
.../solrj/request/beans/AddReplicaPayload.java | 49 +-
.../request/beans/AddReplicaPropertyPayload.java | 5 +-
.../request/beans/BackupCollectionPayload.java | 31 +-
.../request/beans/BalanceShardUniquePayload.java | 6 +-
.../solrj/request/beans/ClusterPropPayload.java | 45 +-
.../solrj/request/beans/CreateAliasPayload.java | 64 +-
.../solrj/request/beans/CreateConfigPayload.java | 7 +-
.../solrj/request/beans/CreateCorePayload.java | 67 +-
.../client/solrj/request/beans/CreatePayload.java | 51 +-
.../solrj/request/beans/CreateShardPayload.java | 32 +-
.../solrj/request/beans/DeleteAliasPayload.java | 7 +-
.../solrj/request/beans/DeleteBackupPayload.java | 18 +-
.../solrj/request/beans/ForceLeaderPayload.java | 2 +-
.../solrj/request/beans/InvokeClassPayload.java | 7 +-
.../solrj/request/beans/ListBackupPayload.java | 9 +-
.../solrj/request/beans/MigrateDocsPayload.java | 9 +-
.../request/beans/ModifyCollectionPayload.java | 18 +-
.../solrj/request/beans/MoveReplicaPayload.java | 21 +-
.../request/beans/OverseerOperationPayload.java | 6 +-
.../solr/client/solrj/request/beans/Package.java | 15 +-
.../client/solrj/request/beans/PluginMeta.java | 20 +-
.../solrj/request/beans/RateLimiterPayload.java | 37 +-
.../request/beans/RebalanceLeadersPayload.java | 6 +-
.../request/beans/RejoinLeaderElectionPayload.java | 22 +-
.../request/beans/ReloadCollectionPayload.java | 3 +-
.../request/beans/RestoreCollectionPayload.java | 33 +-
.../request/beans/SetAliasPropertyPayload.java | 13 +-
.../beans/SetCollectionPropertyPayload.java | 3 +-
.../solrj/request/beans/SplitShardPayload.java | 43 +-
.../solrj/request/beans/SyncShardPayload.java | 6 +-
.../client/solrj/request/beans/V2ApiConstants.java | 49 +-
.../client/solrj/request/beans/package-info.java | 6 +-
.../solrj/request/json/DirectJsonQueryRequest.java | 14 +-
.../solr/client/solrj/request/json/DomainMap.java | 27 +-
.../client/solrj/request/json/HeatmapFacetMap.java | 36 +-
.../client/solrj/request/json/JsonFacetMap.java | 9 +-
.../solrj/request/json/JsonQueryRequest.java | 202 +-
.../client/solrj/request/json/QueryFacetMap.java | 6 +-
.../client/solrj/request/json/RangeFacetMap.java | 33 +-
.../client/solrj/request/json/TermsFacetMap.java | 86 +-
.../client/solrj/request/json/package-info.java | 6 +-
.../solr/client/solrj/request/package-info.java | 8 +-
.../solrj/request/schema/AnalyzerDefinition.java | 2 +-
.../solrj/request/schema/FieldTypeDefinition.java | 5 +-
.../client/solrj/request/schema/SchemaRequest.java | 202 +-
.../client/solrj/request/schema/package-info.java | 4 +-
.../solrj/response/AnalysisResponseBase.java | 66 +-
.../apache/solr/client/solrj/response/Cluster.java | 35 +-
.../client/solrj/response/ClusteringResponse.java | 20 +-
.../solrj/response/CollectionAdminResponse.java | 47 +-
.../solrj/response/ConfigSetAdminResponse.java | 12 +-
.../client/solrj/response/CoreAdminResponse.java | 43 +-
.../solrj/response/DelegationTokenResponse.java | 47 +-
.../solrj/response/DocumentAnalysisResponse.java | 57 +-
.../solr/client/solrj/response/FacetField.java | 231 +-
.../solrj/response/FieldAnalysisResponse.java | 77 +-
.../solr/client/solrj/response/FieldStatsInfo.java | 152 +-
.../apache/solr/client/solrj/response/Group.java | 22 +-
.../solr/client/solrj/response/GroupCommand.java | 40 +-
.../solr/client/solrj/response/GroupResponse.java | 3 +-
.../client/solrj/response/HealthCheckResponse.java | 6 +-
.../solr/client/solrj/response/IntervalFacet.java | 44 +-
.../solr/client/solrj/response/LukeResponse.java | 55 +-
.../solr/client/solrj/response/PivotField.java | 67 +-
.../solr/client/solrj/response/QueryResponse.java | 475 ++--
.../solr/client/solrj/response/RangeFacet.java | 41 +-
.../client/solrj/response/RequestStatusState.java | 13 +-
.../client/solrj/response/SolrPingResponse.java | 9 +-
.../client/solrj/response/SolrResponseBase.java | 31 +-
.../client/solrj/response/SpellCheckResponse.java | 59 +-
.../client/solrj/response/SuggesterResponse.java | 16 +-
.../solr/client/solrj/response/Suggestion.java | 82 +-
.../solr/client/solrj/response/TermsResponse.java | 19 +-
.../solr/client/solrj/response/UpdateResponse.java | 5 +-
.../solr/client/solrj/response/V2Response.java | 4 +-
.../solrj/response/json/BucketBasedJsonFacet.java | 59 +-
.../solrj/response/json/BucketJsonFacet.java | 11 +-
.../solrj/response/json/HeatmapJsonFacet.java | 63 +-
.../solrj/response/json/NestableJsonFacet.java | 47 +-
.../client/solrj/response/json/package-info.java | 6 +-
.../solr/client/solrj/response/package-info.java | 7 +-
.../response/schema/FieldTypeRepresentation.java | 4 +-
.../response/schema/SchemaRepresentation.java | 3 -
.../solrj/response/schema/SchemaResponse.java | 87 +-
.../client/solrj/response/schema/package-info.java | 4 +-
.../routing/AffinityReplicaListTransformer.java | 23 +-
.../AffinityReplicaListTransformerFactory.java | 41 +-
.../routing/NodePreferenceRulesComparator.java | 99 +-
.../solr/client/solrj/routing/PreferenceRule.java | 17 +-
.../solrj/routing/ReplicaListTransformer.java | 7 +-
.../routing/ReplicaListTransformerFactory.java | 14 +-
.../RequestReplicaListTransformerGenerator.java | 77 +-
.../routing/ShufflingReplicaListTransformer.java | 7 +-
.../solr/client/solrj/routing/package-info.java | 8 +-
.../solr/client/solrj/util/AsyncListener.java | 13 +-
.../apache/solr/client/solrj/util/ClientUtils.java | 148 +-
.../apache/solr/client/solrj/util/Constants.java | 7 +-
.../client/solrj/util/SolrBasicAuthentication.java | 16 +-
.../client/solrj/util/SolrIdentifierValidator.java | 30 +-
.../solr/client/solrj/util/package-info.java | 8 +-
.../java/org/apache/solr/cluster/api/ApiType.java | 16 +-
.../apache/solr/cluster/api/CollectionConfig.java | 2 -
.../org/apache/solr/cluster/api/HashRange.java | 6 +-
.../java/org/apache/solr/cluster/api/Resource.java | 31 +-
.../java/org/apache/solr/cluster/api/Router.java | 6 +-
.../java/org/apache/solr/cluster/api/Shard.java | 14 +-
.../org/apache/solr/cluster/api/ShardReplica.java | 12 +-
.../org/apache/solr/cluster/api/SimpleMap.java | 61 +-
.../org/apache/solr/cluster/api/SolrCluster.java | 9 +-
.../apache/solr/cluster/api/SolrCollection.java | 3 +-
.../java/org/apache/solr/cluster/api/SolrNode.java | 8 +-
.../org/apache/solr/cluster/api/package-info.java | 6 +-
.../apache/solr/common/AlreadyClosedException.java | 11 +-
.../src/java/org/apache/solr/common/Callable.java | 2 +-
.../solr/common/ConditionalKeyMapWriter.java | 1 -
.../java/org/apache/solr/common/ConfigNode.java | 235 +-
.../apache/solr/common/EmptyEntityResolver.java | 73 +-
.../org/apache/solr/common/EnumFieldValue.java | 55 +-
.../org/apache/solr/common/IteratorWriter.java | 36 +-
.../org/apache/solr/common/LazySolrCluster.java | 717 +++---
.../org/apache/solr/common/MapSerializable.java | 10 +-
.../src/java/org/apache/solr/common/MapWriter.java | 107 +-
.../java/org/apache/solr/common/MapWriterMap.java | 5 +-
.../org/apache/solr/common/NavigableObject.java | 36 +-
.../solr/common/NonExistentCoreException.java | 1 -
.../java/org/apache/solr/common/PushWriter.java | 19 +-
.../java/org/apache/solr/common/SimpleZkMap.java | 199 +-
.../java/org/apache/solr/common/SolrCloseable.java | 4 +-
.../org/apache/solr/common/SolrCloseableLatch.java | 4 +-
.../java/org/apache/solr/common/SolrDocument.java | 387 ++--
.../org/apache/solr/common/SolrDocumentBase.java | 37 +-
.../org/apache/solr/common/SolrDocumentList.java | 37 +-
.../java/org/apache/solr/common/SolrException.java | 102 +-
.../org/apache/solr/common/SolrInputDocument.java | 142 +-
.../org/apache/solr/common/SolrInputField.java | 112 +-
.../java/org/apache/solr/common/SpecProvider.java | 5 +-
.../java/org/apache/solr/common/StringUtils.java | 8 +-
.../apache/solr/common/ToleratedUpdateError.java | 131 +-
.../solr/common/annotation/JsonProperty.java | 9 +-
.../solr/common/annotation/SolrThreadSafe.java | 9 +-
.../solr/common/annotation/SolrThreadUnsafe.java | 7 +-
.../solr/common/annotation/package-info.java | 6 +-
.../java/org/apache/solr/common/cloud/Aliases.java | 268 ++-
.../common/cloud/CloudCollectionsListener.java | 19 +-
.../solr/common/cloud/ClusterProperties.java | 161 +-
.../common/cloud/ClusterPropertiesListener.java | 10 +-
.../org/apache/solr/common/cloud/ClusterState.java | 252 +--
.../apache/solr/common/cloud/ClusterStateUtil.java | 124 +-
.../solr/common/cloud/CollectionProperties.java | 55 +-
.../solr/common/cloud/CollectionPropsWatcher.java | 10 +-
.../common/cloud/CollectionStatePredicate.java | 11 +-
.../solr/common/cloud/CollectionStateWatcher.java | 23 +-
.../solr/common/cloud/CompositeIdRouter.java | 79 +-
.../solr/common/cloud/ConnectionManager.java | 90 +-
.../common/cloud/DefaultConnectionStrategy.java | 23 +-
.../solr/common/cloud/DefaultZkACLProvider.java | 7 +-
.../common/cloud/DefaultZkCredentialsProvider.java | 5 +-
.../apache/solr/common/cloud/DocCollection.java | 208 +-
.../solr/common/cloud/DocCollectionWatcher.java | 13 +-
.../org/apache/solr/common/cloud/DocRouter.java | 120 +-
.../apache/solr/common/cloud/HashBasedRouter.java | 37 +-
.../solr/common/cloud/ImplicitDocRouter.java | 50 +-
.../solr/common/cloud/LiveNodesListener.java | 5 +-
.../solr/common/cloud/NodesSysPropsCacher.java | 115 +-
.../org/apache/solr/common/cloud/OnReconnect.java | 10 +-
.../apache/solr/common/cloud/PerReplicaStates.java | 147 +-
.../solr/common/cloud/PerReplicaStatesOps.java | 499 ++--
.../apache/solr/common/cloud/PlainIdRouter.java | 1 -
.../java/org/apache/solr/common/cloud/Replica.java | 159 +-
.../apache/solr/common/cloud/ReplicaPosition.java | 16 +-
.../org/apache/solr/common/cloud/RoutingRule.java | 17 +-
.../solr/common/cloud/SaslZkACLProvider.java | 18 +-
.../common/cloud/SecurityAwareZkACLProvider.java | 19 +-
.../java/org/apache/solr/common/cloud/Slice.java | 140 +-
.../apache/solr/common/cloud/SolrClassLoader.java | 10 +-
.../org/apache/solr/common/cloud/SolrZkClient.java | 511 +++--
.../apache/solr/common/cloud/SolrZooKeeper.java | 110 +-
.../VMParamsAllAndReadonlyDigestZkACLProvider.java | 108 +-
...eSetCredentialsDigestZkCredentialsProvider.java | 24 +-
.../apache/solr/common/cloud/ZkACLProvider.java | 4 +-
.../common/cloud/ZkClientConnectionStrategy.java | 31 +-
.../apache/solr/common/cloud/ZkCmdExecutor.java | 66 +-
.../apache/solr/common/cloud/ZkCoreNodeProps.java | 21 +-
.../solr/common/cloud/ZkCredentialsProvider.java | 11 +-
.../apache/solr/common/cloud/ZkDynamicConfig.java | 93 +-
.../solr/common/cloud/ZkMaintenanceUtils.java | 267 ++-
.../org/apache/solr/common/cloud/ZkNodeProps.java | 73 +-
.../org/apache/solr/common/cloud/ZkOperation.java | 18 +-
.../apache/solr/common/cloud/ZkStateReader.java | 1237 +++++-----
.../solr/common/cloud/ZooKeeperException.java | 3 +-
.../org/apache/solr/common/cloud/package-info.java | 8 +-
.../solr/common/cloud/rule/ImplicitSnitch.java | 40 +-
.../org/apache/solr/common/cloud/rule/Snitch.java | 4 +-
.../solr/common/cloud/rule/SnitchContext.java | 35 +-
.../solr/common/cloud/rule/package-info.java | 4 +-
.../org/apache/solr/common/luke/FieldFlag.java | 31 +-
.../org/apache/solr/common/luke/package-info.java | 8 +-
.../java/org/apache/solr/common/package-info.java | 10 +-
.../apache/solr/common/params/AnalysisParams.java | 27 +-
.../solr/common/params/AppendedSolrParams.java | 11 +-
.../solr/common/params/CollectionAdminParams.java | 59 +-
.../solr/common/params/CollectionParams.java | 46 +-
.../solr/common/params/CommonAdminParams.java | 7 +-
.../apache/solr/common/params/CommonParams.java | 197 +-
.../apache/solr/common/params/ConfigSetParams.java | 20 +-
.../apache/solr/common/params/CoreAdminParams.java | 172 +-
.../solr/common/params/CursorMarkParams.java | 25 +-
.../solr/common/params/DefaultSolrParams.java | 14 +-
.../apache/solr/common/params/DisMaxParams.java | 54 +-
.../org/apache/solr/common/params/EventParams.java | 8 +-
.../apache/solr/common/params/ExpandParams.java | 5 +-
.../org/apache/solr/common/params/FacetParams.java | 432 ++--
.../org/apache/solr/common/params/GroupParams.java | 33 +-
.../apache/solr/common/params/HighlightParams.java | 106 +-
.../apache/solr/common/params/MapSolrParams.java | 32 +-
.../solr/common/params/ModifiableSolrParams.java | 175 +-
.../solr/common/params/MoreLikeThisParams.java | 66 +-
.../solr/common/params/MultiMapSolrParams.java | 56 +-
.../solr/common/params/QueryElevationParams.java | 31 +-
.../solr/common/params/RequiredSolrParams.java | 71 +-
.../org/apache/solr/common/params/ShardParams.java | 40 +-
.../apache/solr/common/params/SimpleParams.java | 24 +-
.../org/apache/solr/common/params/SolrParams.java | 444 ++--
.../apache/solr/common/params/SpatialParams.java | 21 +-
.../apache/solr/common/params/SpellingParams.java | 228 +-
.../org/apache/solr/common/params/StatsParams.java | 4 +-
.../apache/solr/common/params/StreamParams.java | 4 +-
.../solr/common/params/TermVectorParams.java | 46 +-
.../org/apache/solr/common/params/TermsParams.java | 107 +-
.../apache/solr/common/params/UpdateParams.java | 24 +-
.../apache/solr/common/params/package-info.java | 7 +-
.../common/util/ByteArrayUtf8CharSequence.java | 72 +-
.../org/apache/solr/common/util/ByteUtils.java | 111 +-
.../org/apache/solr/common/util/BytesBlock.java | 8 +-
.../apache/solr/common/util/BytesOutputStream.java | 12 +-
.../java/org/apache/solr/common/util/Cache.java | 4 +-
.../apache/solr/common/util/CommandOperation.java | 136 +-
.../solr/common/util/CommonTestInjection.java | 4 +-
.../org/apache/solr/common/util/ContentStream.java | 47 +-
.../apache/solr/common/util/ContentStreamBase.java | 187 +-
.../java/org/apache/solr/common/util/DOMUtil.java | 371 +--
.../org/apache/solr/common/util/DataEntry.java | 77 +-
.../solr/common/util/DataInputInputStream.java | 20 +-
.../org/apache/solr/common/util/ExecutorUtil.java | 217 +-
.../apache/solr/common/util/FastInputStream.java | 86 +-
.../solr/common/util/FastJavaBinDecoder.java | 116 +-
.../apache/solr/common/util/FastOutputStream.java | 95 +-
.../org/apache/solr/common/util/FastWriter.java | 40 +-
.../src/java/org/apache/solr/common/util/Hash.java | 533 +++--
.../java/org/apache/solr/common/util/IOUtils.java | 3 +-
.../org/apache/solr/common/util/JavaBinCodec.java | 381 ++--
.../apache/solr/common/util/JsonRecordReader.java | 279 ++-
.../apache/solr/common/util/JsonSchemaCreator.java | 20 +-
.../solr/common/util/JsonSchemaValidator.java | 121 +-
.../apache/solr/common/util/JsonTextWriter.java | 129 +-
.../apache/solr/common/util/MapBackedCache.java | 1 -
.../org/apache/solr/common/util/MurmurHash2.java | 31 +-
.../org/apache/solr/common/util/NamedList.java | 500 ++--
.../org/apache/solr/common/util/ObjectCache.java | 10 +-
.../solr/common/util/ObjectReleaseTracker.java | 51 +-
.../src/java/org/apache/solr/common/util/Pair.java | 14 +-
.../java/org/apache/solr/common/util/PathTrie.java | 71 +-
.../apache/solr/common/util/PropertiesUtil.java | 75 +-
.../apache/solr/common/util/ReflectMapWriter.java | 2 -
.../org/apache/solr/common/util/RetryUtil.java | 35 +-
.../apache/solr/common/util/SimpleOrderedMap.java | 45 +-
.../apache/solr/common/util/SolrJSONWriter.java | 15 +-
.../solr/common/util/SolrNamedThreadFactory.java | 42 +-
.../java/org/apache/solr/common/util/StrUtils.java | 83 +-
.../org/apache/solr/common/util/StringBytes.java | 9 +-
.../apache/solr/common/util/SuppressForbidden.java | 5 +-
.../java/org/apache/solr/common/util/Template.java | 11 +-
.../org/apache/solr/common/util/TextWriter.java | 74 +-
.../org/apache/solr/common/util/TimeSource.java | 102 +-
.../java/org/apache/solr/common/util/URLUtil.java | 15 +-
.../apache/solr/common/util/Utf8CharSequence.java | 23 +-
.../java/org/apache/solr/common/util/Utils.java | 386 ++--
.../apache/solr/common/util/ValidatingJsonMap.java | 89 +-
.../apache/solr/common/util/WrappedSimpleMap.java | 39 +-
.../src/java/org/apache/solr/common/util/XML.java | 66 +-
.../apache/solr/common/util/XMLErrorLogger.java | 29 +-
.../org/apache/solr/common/util/package-info.java | 8 +-
solr/solrj/src/java/org/noggit/CharArr.java | 65 +-
solr/solrj/src/java/org/noggit/JSONParser.java | 451 ++--
solr/solrj/src/java/org/noggit/JSONUtil.java | 33 +-
solr/solrj/src/java/org/noggit/JSONWriter.java | 25 +-
solr/solrj/src/java/org/noggit/ObjectBuilder.java | 40 +-
solr/solrj/src/java/org/noggit/package-info.java | 8 +-
.../IndexingNestedDocuments.java | 84 +-
.../JsonRequestApiHeatmapFacetingTest.java | 66 +-
.../ref_guide_examples/JsonRequestApiTest.java | 426 ++--
.../UsingSolrJRefGuideExamplesTest.java | 40 +-
.../ref_guide_examples/ZkConfigFilesTest.java | 14 +-
.../CollectionAdminRequestRequiredParamsTest.java | 188 +-
.../org/apache/solr/client/solrj/GetByIdTest.java | 30 +-
.../solr/client/solrj/LargeVolumeTestBase.java | 42 +-
.../client/solrj/MergeIndexesExampleTestBase.java | 51 +-
.../client/solrj/SolrExampleBinaryHttp2Test.java | 18 +-
.../solr/client/solrj/SolrExampleBinaryTest.java | 14 +-
.../apache/solr/client/solrj/SolrExampleTests.java | 2387 +++++++++++++-------
.../solr/client/solrj/SolrExampleTestsBase.java | 144 +-
.../solr/client/solrj/SolrExampleXMLTest.java | 7 +-
.../solr/client/solrj/SolrExceptionTest.java | 21 +-
.../apache/solr/client/solrj/SolrQueryTest.java | 179 +-
.../client/solrj/SolrSchemalessExampleTest.java | 66 +-
.../apache/solr/client/solrj/StartSolrJetty.java | 31 +-
.../apache/solr/client/solrj/TestBatchUpdate.java | 107 +-
.../solr/client/solrj/TestLBHttp2SolrClient.java | 41 +-
.../solr/client/solrj/TestLBHttpSolrClient.java | 56 +-
.../solr/client/solrj/TestSolrJErrorHandling.java | 182 +-
.../solrj/beans/TestDocumentObjectBinder.java | 104 +-
.../AbstractEmbeddedSolrServerTestCase.java | 24 +-
.../client/solrj/embedded/JettyWebappTest.java | 42 +-
.../solrj/embedded/LargeVolumeBinaryJettyTest.java | 1 -
.../solrj/embedded/LargeVolumeJettyTest.java | 2 -
.../solrj/embedded/MergeIndexesEmbeddedTest.java | 1 -
.../solrj/embedded/SolrExampleEmbeddedTest.java | 3 +-
.../solrj/embedded/SolrExampleJettyTest.java | 83 +-
.../SolrExampleStreamingBinaryHttp2Test.java | 32 +-
.../embedded/SolrExampleStreamingBinaryTest.java | 24 +-
.../embedded/SolrExampleStreamingHttp2Test.java | 32 +-
.../solrj/embedded/SolrExampleStreamingTest.java | 67 +-
.../solrj/embedded/SolrExampleXMLHttp2Test.java | 3 +-
.../solrj/embedded/TestEmbeddedSolrServer.java | 10 +-
.../client/solrj/embedded/TestSolrProperties.java | 16 +-
.../client/solrj/impl/BasicHttpSolrClientTest.java | 489 ++--
.../impl/CloudHttp2SolrClientBadInputTest.java | 44 +-
.../impl/CloudHttp2SolrClientBuilderTest.java | 72 +-
.../CloudHttp2SolrClientMultiConstructorTest.java | 23 +-
.../solrj/impl/CloudHttp2SolrClientRetryTest.java | 27 +-
.../solrj/impl/CloudHttp2SolrClientTest.java | 524 +++--
.../solrj/impl/CloudSolrClientBadInputTest.java | 42 +-
.../solrj/impl/CloudSolrClientBuilderTest.java | 48 +-
.../solrj/impl/CloudSolrClientCacheTest.java | 148 +-
.../impl/CloudSolrClientMultiConstructorTest.java | 36 +-
.../solrj/impl/CloudSolrClientRetryTest.java | 21 +-
.../client/solrj/impl/CloudSolrClientTest.java | 550 +++--
...oncurrentUpdateHttp2SolrClientBadInputTest.java | 102 +-
...ntUpdateHttp2SolrClientMultiCollectionTest.java | 33 +-
.../impl/ConcurrentUpdateHttp2SolrClientTest.java | 131 +-
.../ConcurrentUpdateSolrClientBadInputTest.java | 90 +-
.../ConcurrentUpdateSolrClientBuilderTest.java | 30 +-
...currentUpdateSolrClientMultiCollectionTest.java | 31 +-
.../solrj/impl/ConcurrentUpdateSolrClientTest.java | 248 +-
.../impl/Http2SolrClientCompatibilityTest.java | 62 +-
.../client/solrj/impl/Http2SolrClientTest.java | 366 +--
.../solr/client/solrj/impl/HttpClientUtilTest.java | 147 +-
.../client/solrj/impl/HttpClusterStateSSLTest.java | 31 +-
.../solrj/impl/HttpSolrClientBadInputTest.java | 90 +-
.../solrj/impl/HttpSolrClientBuilderTest.java | 29 +-
.../solrj/impl/HttpSolrClientConPoolTest.java | 123 +-
.../impl/HttpSolrClientSSLAuthConPoolTest.java | 20 +-
.../solrj/impl/LBHttpSolrClientBadInputTest.java | 83 +-
.../solrj/impl/LBHttpSolrClientBuilderTest.java | 32 +-
.../client/solrj/impl/LBHttpSolrClientTest.java | 42 +-
.../solr/client/solrj/impl/LBSolrClientTest.java | 33 +-
...reemptiveBasicAuthClientBuilderFactoryTest.java | 107 +-
.../solrj/impl/SolrPortAwareCookieSpecTest.java | 14 +-
.../solrj/impl/TestCloudSolrClientConnections.java | 71 +-
.../org/apache/solr/client/solrj/io/TestLang.java | 369 ++-
.../org/apache/solr/client/solrj/io/TupleTest.java | 379 ++--
.../client/solrj/io/graph/GraphExpressionTest.java | 989 ++++----
.../solr/client/solrj/io/graph/GraphTest.java | 123 +-
.../solr/client/solrj/io/sql/JdbcDriverTest.java | 23 +-
.../apache/solr/client/solrj/io/sql/JdbcTest.java | 325 ++-
.../io/stream/eval/AbsoluteValueEvaluatorTest.java | 57 +-
.../solrj/io/stream/eval/AddEvaluatorTest.java | 108 +-
.../solrj/io/stream/eval/AndEvaluatorTest.java | 37 +-
.../solrj/io/stream/eval/AppendEvaluatorTest.java | 30 +-
.../io/stream/eval/ArcCosineEvaluatorTest.java | 46 +-
.../solrj/io/stream/eval/ArcSineEvaluatorTest.java | 46 +-
.../io/stream/eval/ArcTangentEvaluatorTest.java | 46 +-
.../solrj/io/stream/eval/ArrayEvaluatorTest.java | 111 +-
.../solrj/io/stream/eval/AscEvaluatorTest.java | 139 +-
.../solrj/io/stream/eval/CeilingEvaluatorTest.java | 41 +-
.../io/stream/eval/CoalesceEvaluatorTest.java | 27 +-
.../io/stream/eval/ConversionEvaluatorsTest.java | 50 +-
.../io/stream/eval/CorrelationEvaluatorTest.java | 17 +-
.../solrj/io/stream/eval/CosineEvaluatorTest.java | 47 +-
.../io/stream/eval/CubedRootEvaluatorTest.java | 46 +-
.../eval/CumulativeProbabilityEvaluatorTest.java | 22 +-
.../solrj/io/stream/eval/DivideEvaluatorTest.java | 77 +-
.../eval/EmpiricalDistributionEvaluatorTest.java | 14 +-
.../solrj/io/stream/eval/EqualToEvaluatorTest.java | 110 +-
.../io/stream/eval/ExclusiveOrEvaluatorTest.java | 37 +-
.../io/stream/eval/FieldValueEvaluatorTest.java | 202 +-
.../solrj/io/stream/eval/FloorEvaluatorTest.java | 42 +-
.../eval/GreaterThanEqualToEvaluatorTest.java | 96 +-
.../io/stream/eval/GreaterThanEvaluatorTest.java | 96 +-
.../stream/eval/HyperbolicCosineEvaluatorTest.java | 46 +-
.../stream/eval/HyperbolicSineEvaluatorTest.java | 46 +-
.../eval/HyperbolicTangentEvaluatorTest.java | 48 +-
.../solrj/io/stream/eval/LengthEvaluatorTest.java | 88 +-
.../stream/eval/LessThanEqualToEvaluatorTest.java | 98 +-
.../io/stream/eval/LessThanEvaluatorTest.java | 96 +-
.../solrj/io/stream/eval/ModuloEvaluatorTest.java | 75 +-
.../io/stream/eval/MultiplyEvaluatorTest.java | 71 +-
.../io/stream/eval/NaturalLogEvaluatorTest.java | 26 +-
.../eval/NormalDistributionEvaluatorTest.java | 17 +-
.../io/stream/eval/NormalizeEvaluatorTest.java | 47 +-
.../solrj/io/stream/eval/NotEvaluatorTest.java | 30 +-
.../solrj/io/stream/eval/OrEvaluatorTest.java | 37 +-
.../solrj/io/stream/eval/PowerEvaluatorTest.java | 54 +-
.../io/stream/eval/RawValueEvaluatorTest.java | 38 +-
.../io/stream/eval/RecursiveEvaluatorTest.java | 35 +-
.../io/stream/eval/RegressionEvaluatorTest.java | 24 +-
.../solrj/io/stream/eval/ReverseEvaluatorTest.java | 14 +-
.../solrj/io/stream/eval/RoundEvaluatorTest.java | 46 +-
.../solrj/io/stream/eval/SineEvaluatorTest.java | 46 +-
.../io/stream/eval/SquareRootEvaluatorTest.java | 46 +-
.../io/stream/eval/SubtractEvaluatorTest.java | 71 +-
.../solrj/io/stream/eval/TangentEvaluatorTest.java | 46 +-
.../io/stream/eval/TemporalEvaluatorsTest.java | 121 +-
.../eval/UniformDistributionEvaluatorTest.java | 18 +-
.../solrj/io/stream/eval/UuidEvaluatorTest.java | 21 +-
.../solrj/io/stream/expr/InjectionDefenseTest.java | 38 +-
.../io/stream/expr/StreamExpressionParserTest.java | 150 +-
.../io/stream/metrics/WeightedSumMetricTest.java | 16 +-
.../solrj/io/stream/ops/ConcatOperationTest.java | 194 +-
.../client/solrj/io/stream/ops/OperationsTest.java | 142 +-
.../solr/client/solrj/request/SchemaTest.java | 372 +--
.../solr/client/solrj/request/SolrPingTest.java | 16 +-
.../solrj/request/TestCollectionAdminRequest.java | 90 +-
.../solrj/request/TestConfigSetAdminRequest.java | 63 +-
.../solr/client/solrj/request/TestCoreAdmin.java | 106 +-
.../solrj/request/TestDelegationTokenRequest.java | 5 +-
.../solr/client/solrj/request/TestLukeRequest.java | 4 +-
.../client/solrj/request/TestUpdateRequest.java | 5 +-
.../solrj/request/TestUpdateRequestCodec.java | 156 +-
.../solr/client/solrj/request/TestV2Request.java | 167 +-
...DirectJsonQueryRequestFacetingEmbeddedTest.java | 566 +++--
...ectJsonQueryRequestFacetingIntegrationTest.java | 596 +++--
.../client/solrj/request/json/DomainMapTest.java | 127 +-
.../solrj/request/json/HeatmapFacetMapTest.java | 92 +-
.../JsonQueryRequestFacetingIntegrationTest.java | 446 ++--
.../json/JsonQueryRequestHeatmapFacetingTest.java | 53 +-
.../json/JsonQueryRequestIntegrationTest.java | 122 +-
.../request/json/JsonQueryRequestUnitTest.java | 266 ++-
.../solrj/request/json/QueryFacetMapTest.java | 13 +-
.../solrj/request/json/RangeFacetMapTest.java | 53 +-
.../solrj/request/json/TermsFacetMapTest.java | 114 +-
.../solrj/response/AnlysisResponseBaseTest.java | 38 +-
.../response/DocumentAnalysisResponseTest.java | 31 +-
.../solrj/response/FieldAnalysisResponseTest.java | 33 +-
.../solrj/response/NestableJsonFacetTest.java | 118 +-
.../solrj/response/NoOpResponseParserTest.java | 24 +-
.../client/solrj/response/QueryResponseTest.java | 56 +-
.../client/solrj/response/TermsResponseTest.java | 10 +-
.../solrj/response/TestClusteringResponse.java | 29 +-
.../response/TestDelegationTokenResponse.java | 47 +-
.../solrj/response/TestSpellCheckResponse.java | 58 +-
.../solrj/response/TestSuggesterResponse.java | 16 +-
.../routing/NodePreferenceRulesComparatorTest.java | 125 +-
.../solrj/routing/ReplicaListTransformerTest.java | 101 +-
...RequestReplicaListTransformerGeneratorTest.java | 66 +-
.../ShufflingReplicaListTransformerTest.java | 15 +-
.../solr/client/solrj/util/ClientUtilsTest.java | 21 +-
.../org/apache/solr/common/SolrDocumentTest.java | 321 +--
.../solr/common/TestToleratedUpdateError.java | 133 +-
.../cloud/PerReplicaStatesIntegrationTest.java | 164 +-
.../apache/solr/common/cloud/SolrZkClientTest.java | 147 +-
.../cloud/TestCloudCollectionsListeners.java | 222 +-
.../common/cloud/TestCollectionStateWatchers.java | 328 +--
.../common/cloud/TestDocCollectionWatcher.java | 249 +-
.../solr/common/cloud/TestPerReplicaStates.java | 92 +-
.../solr/common/cloud/TestZkConfigSetService.java | 137 +-
.../solr/common/cloud/TestZkMaintenanceUtils.java | 108 +-
.../solr/common/params/CommonAdminParamsTest.java | 11 +-
.../solr/common/params/CommonParamsTest.java | 31 +-
.../common/params/ModifiableSolrParamsTest.java | 63 +-
.../apache/solr/common/params/ShardParamsTest.java | 94 +-
.../apache/solr/common/params/SolrParamTest.java | 281 ++-
.../apache/solr/common/util/ContentStreamTest.java | 119 +-
.../org/apache/solr/common/util/DOMUtilTest.java | 60 +-
.../apache/solr/common/util/JsonValidatorTest.java | 277 ++-
.../org/apache/solr/common/util/NamedListTest.java | 16 +-
.../solr/common/util/TestFastInputStream.java | 30 +-
.../solr/common/util/TestFastJavabinDecoder.java | 287 +--
.../apache/solr/common/util/TestFastWriter.java | 33 +-
.../test/org/apache/solr/common/util/TestHash.java | 72 +-
.../apache/solr/common/util/TestJavaBinCodec.java | 368 +--
.../solr/common/util/TestJsonRecordReader.java | 1074 +++++----
.../solr/common/util/TestNamedListCodec.java | 152 +-
.../org/apache/solr/common/util/TestPathTrie.java | 23 +-
.../org/apache/solr/common/util/TestRetryUtil.java | 60 +-
.../solr/common/util/TestSolrJsonWriter.java | 115 +-
.../apache/solr/common/util/TestTimeSource.java | 8 +-
.../solr/common/util/TestValidatingJsonMap.java | 33 +-
.../apache/solr/common/util/TestXMLEscaping.java | 35 +-
.../org/apache/solr/common/util/URLUtilTest.java | 3 +-
.../solr/common/util/Utf8CharSequenceTest.java | 17 +-
solr/solrj/src/test/org/noggit/TestJSONParser.java | 758 ++++---
solr/solrj/src/test/org/noggit/TestJSONWriter.java | 32 +-
.../src/test/org/noggit/TestObjectBuilder.java | 113 +-
971 files changed, 42372 insertions(+), 35634 deletions(-)
diff --git a/gradle/validation/spotless.gradle b/gradle/validation/spotless.gradle
index c51e544..3f72246 100644
--- a/gradle/validation/spotless.gradle
+++ b/gradle/validation/spotless.gradle
@@ -45,9 +45,11 @@ configure(project(":solr").subprojects) { prj ->
// Exclude certain files (generated ones, mostly).
switch (project.path) {
case ":solr:core":
- case ":solr:solrj":
targetExclude "src/**/*.java"
break
+ case ":solr:solrj":
+ targetExclude "src/test/org/apache/solr/client/solrj/io/stream/*.java"
+ break
case ":solr:modules:hdfs":
// Exclude Hadoop copied files to make upgrades easier
targetExclude "src/**/org/apache/hadoop/**"
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/FastStreamingDocsCallback.java b/solr/solrj/src/java/org/apache/solr/client/solrj/FastStreamingDocsCallback.java
index 57701ff..8398a13 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/FastStreamingDocsCallback.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/FastStreamingDocsCallback.java
@@ -17,23 +17,24 @@
package org.apache.solr.client.solrj;
-
import org.apache.solr.common.util.DataEntry;
public interface FastStreamingDocsCallback {
- /** callback for a doclist
+ /**
+ * callback for a doclist
*
- * @return the object to be shared with all the {{@link #startDoc(Object)}} calls. return null if nothing needs to be shared
+ * @return the object to be shared with all the {{@link #startDoc(Object)}} calls. return null if
+ * nothing needs to be shared
*/
default Object initDocList(Long numFound, Long start, Float maxScore) {
return null;
}
-
/**
* Started a document
*
- * @param docListObj This object is the value returned by the {{@link #initDocList(Long, Long, Float)}} method
+ * @param docListObj This object is the value returned by the {{@link #initDocList(Long, Long,
+ * Float)}} method
* @return any arbitrary object that should be shared between each field
*/
Object startDoc(Object docListObj);
@@ -41,7 +42,7 @@ public interface FastStreamingDocsCallback {
/**
* FOund a new field
*
- * @param field Read the appropriate value
+ * @param field Read the appropriate value
* @param docObj The object returned by {{@link #startDoc(Object)}} method
*/
void field(DataEntry field, Object docObj);
@@ -51,16 +52,16 @@ public interface FastStreamingDocsCallback {
*
* @param docObj The object returned by {{@link #startDoc(Object)}} method
*/
- default void endDoc(Object docObj) { }
+ default void endDoc(Object docObj) {}
- /** A new child doc starts
- * @param parentDocObj an objec that will be shared across all the {{@link FastStreamingDocsCallback#field(DataEntry, Object)}}
+ /**
+ * A new child doc starts
+ *
+ * @param parentDocObj an objec that will be shared across all the {{@link
+ * FastStreamingDocsCallback#field(DataEntry, Object)}}
* @return any custom object that be shared with the fields in this child doc
*/
default Object startChildDoc(Object parentDocObj) {
return null;
}
-
-
-
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/ResponseParser.java b/solr/solrj/src/java/org/apache/solr/client/solrj/ResponseParser.java
index c08d165..0268b51 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/ResponseParser.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/ResponseParser.java
@@ -16,37 +16,29 @@
*/
package org.apache.solr.client.solrj;
-import java.io.Reader;
import java.io.InputStream;
+import java.io.Reader;
import org.apache.solr.common.util.NamedList;
-/**
- *
- *
- * @since solr 1.3
- */
-public abstract class ResponseParser
-{
+/** @since solr 1.3 */
+public abstract class ResponseParser {
public abstract String getWriterType(); // for example: wt=XML, JSON, etc
public abstract NamedList<Object> processResponse(InputStream body, String encoding);
public abstract NamedList<Object> processResponse(Reader reader);
-
+
/**
* A well behaved ResponseParser will return its content-type.
- *
+ *
* @return the content-type this parser expects to parse
*/
public String getContentType() {
return null;
}
-
- /**
- * @return the version param passed to solr
- */
- public String getVersion()
- {
+
+ /** @return the version param passed to solr */
+ public String getVersion() {
return "2.2";
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/RoutedAliasTypes.java b/solr/solrj/src/java/org/apache/solr/client/solrj/RoutedAliasTypes.java
index bad1bcf..9649052 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/RoutedAliasTypes.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/RoutedAliasTypes.java
@@ -17,12 +17,11 @@
package org.apache.solr.client.solrj;
-
/**
* Types of Routed Alias supported.
*
- * Routed Alias collections have a naming pattern of XYZ where X is the alias name, Y is the separator prefix and
- * Z is the data driven value distinguishing the bucket.
+ * <p>Routed Alias collections have a naming pattern of XYZ where X is the alias name, Y is the
+ * separator prefix and Z is the data driven value distinguishing the bucket.
*/
public enum RoutedAliasTypes {
TIME {
@@ -42,6 +41,6 @@ public enum RoutedAliasTypes {
throw new UnsupportedOperationException("dimensions within dimensions are not allowed");
}
};
- public abstract String getSeparatorPrefix();
+ public abstract String getSeparatorPrefix();
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java
index b23c9de..3043118 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrClient.java
@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-
import org.apache.solr.client.solrj.SolrRequest.METHOD;
import org.apache.solr.client.solrj.beans.DocumentObjectBinder;
import org.apache.solr.client.solrj.impl.StreamingBinaryResponseParser;
@@ -59,30 +58,27 @@ public abstract class SolrClient implements Serializable, Closeable {
* Adds a collection of documents
*
* @param collection the Solr collection to add documents to
- * @param docs the collection of documents
- *
+ * @param docs the collection of documents
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
- *
* @since Solr 5.1
*/
- public UpdateResponse add(String collection, Collection<SolrInputDocument> docs) throws SolrServerException, IOException {
+ public UpdateResponse add(String collection, Collection<SolrInputDocument> docs)
+ throws SolrServerException, IOException {
return add(collection, docs, -1);
}
/**
* Adds a collection of documents
*
- * @param docs the collection of documents
- *
+ * @param docs the collection of documents
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse add(Collection<SolrInputDocument> docs) throws SolrServerException, IOException {
+ public UpdateResponse add(Collection<SolrInputDocument> docs)
+ throws SolrServerException, IOException {
return add(null, docs);
}
@@ -90,17 +86,16 @@ public abstract class SolrClient implements Serializable, Closeable {
* Adds a collection of documents, specifying max time before they become committed
*
* @param collection the Solr collection to add documents to
- * @param docs the collection of documents
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param docs the collection of documents
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
- *
* @since Solr 5.1
*/
- public UpdateResponse add(String collection, Collection<SolrInputDocument> docs, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse add(
+ String collection, Collection<SolrInputDocument> docs, int commitWithinMs)
+ throws SolrServerException, IOException {
UpdateRequest req = new UpdateRequest();
req.add(docs);
req.setCommitWithin(commitWithinMs);
@@ -110,17 +105,15 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Adds a collection of documents, specifying max time before they become committed
*
- * @param docs the collection of documents
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param docs the collection of documents
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
- *
* @since Solr 3.5
*/
- public UpdateResponse add(Collection<SolrInputDocument> docs, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse add(Collection<SolrInputDocument> docs, int commitWithinMs)
+ throws SolrServerException, IOException {
return add(null, docs, commitWithinMs);
}
@@ -128,29 +121,26 @@ public abstract class SolrClient implements Serializable, Closeable {
* Adds a single document
*
* @param collection the Solr collection to add the document to
- * @param doc the input document
- *
+ * @param doc the input document
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse add(String collection, SolrInputDocument doc) throws SolrServerException, IOException {
+ public UpdateResponse add(String collection, SolrInputDocument doc)
+ throws SolrServerException, IOException {
return add(collection, doc, -1);
}
/**
* Adds a single document
*
- * Many {@link SolrClient} implementations have drastically slower indexing performance when documents are added
- * individually. Document batching generally leads to better indexing performance and should be used whenever
- * possible.
- *
- * @param doc the input document
+ * <p>Many {@link SolrClient} implementations have drastically slower indexing performance when
+ * documents are added individually. Document batching generally leads to better indexing
+ * performance and should be used whenever possible.
*
+ * @param doc the input document
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse add(SolrInputDocument doc) throws SolrServerException, IOException {
@@ -161,17 +151,15 @@ public abstract class SolrClient implements Serializable, Closeable {
* Adds a single document specifying max time before it becomes committed
*
* @param collection the Solr collection to add the document to
- * @param doc the input document
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param doc the input document
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
- *
* @since solr 5.1
*/
- public UpdateResponse add(String collection, SolrInputDocument doc, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse add(String collection, SolrInputDocument doc, int commitWithinMs)
+ throws SolrServerException, IOException {
UpdateRequest req = new UpdateRequest();
req.add(doc);
req.setCommitWithin(commitWithinMs);
@@ -181,17 +169,15 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Adds a single document specifying max time before it becomes committed
*
- * @param doc the input document
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param doc the input document
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
- *
* @since solr 3.5
*/
- public UpdateResponse add(SolrInputDocument doc, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse add(SolrInputDocument doc, int commitWithinMs)
+ throws SolrServerException, IOException {
return add(null, doc, commitWithinMs);
}
@@ -199,12 +185,9 @@ public abstract class SolrClient implements Serializable, Closeable {
* Adds the documents supplied by the given iterator.
*
* @param collection the Solr collection to add the documents to
- * @param docIterator
- * the iterator which returns SolrInputDocument instances
- *
+ * @param docIterator the iterator which returns SolrInputDocument instances
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse add(String collection, Iterator<SolrInputDocument> docIterator)
@@ -217,51 +200,46 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Adds the documents supplied by the given iterator.
*
- * @param docIterator
- * the iterator which returns SolrInputDocument instances
- *
+ * @param docIterator the iterator which returns SolrInputDocument instances
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse add(Iterator<SolrInputDocument> docIterator) throws SolrServerException, IOException {
+ public UpdateResponse add(Iterator<SolrInputDocument> docIterator)
+ throws SolrServerException, IOException {
return add(null, docIterator);
}
/**
* Adds a single bean
*
- * The bean is converted to a {@link SolrInputDocument} by the client's
- * {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder}
- * <p>
- * Many {@link SolrClient} implementations have drastically slower indexing performance when documents are added
- * individually. Document batching generally leads to better indexing performance and should be used whenever
- * possible.
+ * <p>The bean is converted to a {@link SolrInputDocument} by the client's {@link
+ * org.apache.solr.client.solrj.beans.DocumentObjectBinder}
*
- * @param collection to Solr collection to add documents to
- * @param obj the input bean
+ * <p>Many {@link SolrClient} implementations have drastically slower indexing performance when
+ * documents are added individually. Document batching generally leads to better indexing
+ * performance and should be used whenever possible.
*
+ * @param collection to Solr collection to add documents to
+ * @param obj the input bean
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse addBean(String collection, Object obj) throws IOException, SolrServerException {
+ public UpdateResponse addBean(String collection, Object obj)
+ throws IOException, SolrServerException {
return addBean(collection, obj, -1);
}
/**
* Adds a single bean
*
- * The bean is converted to a {@link SolrInputDocument} by the client's
- * {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder}
- *
- * @param obj the input bean
+ * <p>The bean is converted to a {@link SolrInputDocument} by the client's {@link
+ * org.apache.solr.client.solrj.beans.DocumentObjectBinder}
*
+ * @param obj the input bean
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse addBean(Object obj) throws IOException, SolrServerException {
@@ -271,67 +249,62 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Adds a single bean specifying max time before it becomes committed
*
- * The bean is converted to a {@link SolrInputDocument} by the client's
- * {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder}
+ * <p>The bean is converted to a {@link SolrInputDocument} by the client's {@link
+ * org.apache.solr.client.solrj.beans.DocumentObjectBinder}
*
* @param collection to Solr collection to add documents to
- * @param obj the input bean
- *
+ * @param obj the input bean
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse addBean(String collection, Object obj, int commitWithinMs) throws IOException, SolrServerException {
+ public UpdateResponse addBean(String collection, Object obj, int commitWithinMs)
+ throws IOException, SolrServerException {
return add(collection, getBinder().toSolrInputDocument(obj), commitWithinMs);
}
/**
* Adds a single bean specifying max time before it becomes committed
*
- * The bean is converted to a {@link SolrInputDocument} by the client's
- * {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder}
- *
- * @param obj the input bean
+ * <p>The bean is converted to a {@link SolrInputDocument} by the client's {@link
+ * org.apache.solr.client.solrj.beans.DocumentObjectBinder}
*
+ * @param obj the input bean
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse addBean(Object obj, int commitWithinMs) throws IOException, SolrServerException {
+ public UpdateResponse addBean(Object obj, int commitWithinMs)
+ throws IOException, SolrServerException {
return add(null, getBinder().toSolrInputDocument(obj), commitWithinMs);
}
/**
* Adds a collection of beans
*
- * The beans are converted to {@link SolrInputDocument}s by the client's
- * {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder}
+ * <p>The beans are converted to {@link SolrInputDocument}s by the client's {@link
+ * org.apache.solr.client.solrj.beans.DocumentObjectBinder}
*
* @param collection the Solr collection to add documents to
- * @param beans the collection of beans
- *
+ * @param beans the collection of beans
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse addBeans(String collection, Collection<?> beans) throws SolrServerException, IOException {
+ public UpdateResponse addBeans(String collection, Collection<?> beans)
+ throws SolrServerException, IOException {
return addBeans(collection, beans, -1);
}
/**
* Adds a collection of beans
*
- * The beans are converted to {@link SolrInputDocument}s by the client's
- * {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder}
- *
- * @param beans the collection of beans
+ * <p>The beans are converted to {@link SolrInputDocument}s by the client's {@link
+ * org.apache.solr.client.solrj.beans.DocumentObjectBinder}
*
+ * @param beans the collection of beans
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse addBeans(Collection<?> beans) throws SolrServerException, IOException {
@@ -341,25 +314,22 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Adds a collection of beans specifying max time before they become committed
*
- * The beans are converted to {@link SolrInputDocument}s by the client's
- * {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder}
+ * <p>The beans are converted to {@link SolrInputDocument}s by the client's {@link
+ * org.apache.solr.client.solrj.beans.DocumentObjectBinder}
*
* @param collection the Solr collection to add documents to
- * @param beans the collection of beans
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param beans the collection of beans
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
- *
* @see SolrClient#getBinder()
- *
* @since solr 5.1
*/
- public UpdateResponse addBeans(String collection, Collection<?> beans, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse addBeans(String collection, Collection<?> beans, int commitWithinMs)
+ throws SolrServerException, IOException {
DocumentObjectBinder binder = this.getBinder();
- ArrayList<SolrInputDocument> docs = new ArrayList<>(beans.size());
+ ArrayList<SolrInputDocument> docs = new ArrayList<>(beans.size());
for (Object bean : beans) {
docs.add(binder.toSolrInputDocument(bean));
}
@@ -369,22 +339,19 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Adds a collection of beans specifying max time before they become committed
*
- * The beans are converted to {@link SolrInputDocument}s by the client's
- * {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder}
- *
- * @param beans the collection of beans
- * @param commitWithinMs max time (in ms) before a commit will happen
+ * <p>The beans are converted to {@link SolrInputDocument}s by the client's {@link
+ * org.apache.solr.client.solrj.beans.DocumentObjectBinder}
*
+ * @param beans the collection of beans
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
- *
* @see SolrClient#getBinder()
- *
* @since solr 3.5
*/
- public UpdateResponse addBeans(Collection<?> beans, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse addBeans(Collection<?> beans, int commitWithinMs)
+ throws SolrServerException, IOException {
return addBeans(null, beans, commitWithinMs);
}
@@ -392,68 +359,63 @@ public abstract class SolrClient implements Serializable, Closeable {
* Adds the beans supplied by the given iterator.
*
* @param collection the Solr collection to add the documents to
- * @param beanIterator
- * the iterator which returns Beans
- *
+ * @param beanIterator the iterator which returns Beans
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
public UpdateResponse addBeans(String collection, final Iterator<?> beanIterator)
throws SolrServerException, IOException {
UpdateRequest req = new UpdateRequest();
- req.setDocIterator(new Iterator<SolrInputDocument>() {
-
- @Override
- public boolean hasNext() {
- return beanIterator.hasNext();
- }
-
- @Override
- public SolrInputDocument next() {
- Object o = beanIterator.next();
- if (o == null) return null;
- return getBinder().toSolrInputDocument(o);
- }
-
- @Override
- public void remove() {
- beanIterator.remove();
- }
- });
+ req.setDocIterator(
+ new Iterator<SolrInputDocument>() {
+
+ @Override
+ public boolean hasNext() {
+ return beanIterator.hasNext();
+ }
+
+ @Override
+ public SolrInputDocument next() {
+ Object o = beanIterator.next();
+ if (o == null) return null;
+ return getBinder().toSolrInputDocument(o);
+ }
+
+ @Override
+ public void remove() {
+ beanIterator.remove();
+ }
+ });
return req.process(this, collection);
}
/**
* Adds the beans supplied by the given iterator.
*
- * @param beanIterator
- * the iterator which returns Beans
- *
+ * @param beanIterator the iterator which returns Beans
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server
- *
- * @throws IOException if there is a communication error with the server
+ * @throws IOException if there is a communication error with the server
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse addBeans(final Iterator<?> beanIterator) throws SolrServerException, IOException {
+ public UpdateResponse addBeans(final Iterator<?> beanIterator)
+ throws SolrServerException, IOException {
return addBeans(null, beanIterator);
}
/**
* Performs an explicit commit, causing pending documents to be committed for indexing
*
- * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
- * <p>
- * Be very careful when triggering commits from the client side. Commits are heavy operations and WILL impact Solr
- * performance when executed too often or too close together. Instead, consider using 'commitWithin' when adding documents
- * or rely on your core's/collection's 'autoCommit' settings.
+ * <p>waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
*
- * @param collection the Solr collection to send the commit to
+ * <p>Be very careful when triggering commits from the client side. Commits are heavy operations
+ * and WILL impact Solr performance when executed too often or too close together. Instead,
+ * consider using 'commitWithin' when adding documents or rely on your core's/collection's
+ * 'autoCommit' settings.
*
+ * @param collection the Solr collection to send the commit to
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -464,15 +426,15 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs an explicit commit, causing pending documents to be committed for indexing
*
- * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
- * <p>
- * Be very careful when triggering commits from the client side. Commits are heavy operations and WILL impact Solr
- * performance when executed too often or too close together. Instead, consider using 'commitWithin' when adding documents
- * or rely on your core's/collection's 'autoCommit' settings.
+ * <p>waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
*
- * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
+ * <p>Be very careful when triggering commits from the client side. Commits are heavy operations
+ * and WILL impact Solr performance when executed too often or too close together. Instead,
+ * consider using 'commitWithin' when adding documents or rely on your core's/collection's
+ * 'autoCommit' settings.
*
+ * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -483,18 +445,17 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs an explicit commit, causing pending documents to be committed for indexing
*
- * Be very careful when triggering commits from the client side. Commits are heavy operations and WILL impact Solr
- * performance when executed too often or too close together. Instead, consider using 'commitWithin' when adding documents
- * or rely on your core's/collection's 'autoCommit' settings.
+ * <p>Be very careful when triggering commits from the client side. Commits are heavy operations
+ * and WILL impact Solr performance when executed too often or too close together. Instead,
+ * consider using 'commitWithin' when adding documents or rely on your core's/collection's
+ * 'autoCommit' settings.
*
* @param collection the Solr collection to send the commit to
- * @param waitFlush block until index changes are flushed to disk
- * @param waitSearcher block until a new searcher is opened and registered as the
- * main query searcher, making the changes visible
- *
+ * @param waitFlush block until index changes are flushed to disk
+ * @param waitSearcher block until a new searcher is opened and registered as the main query
+ * searcher, making the changes visible
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -508,45 +469,45 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs an explicit commit, causing pending documents to be committed for indexing
*
- * Be very careful when triggering commits from the client side. Commits are heavy operations and WILL impact Solr
- * performance when executed too often or too close together. Instead, consider using 'commitWithin' when adding documents
- * or rely on your core's/collection's 'autoCommit' settings.
- *
- * @param waitFlush block until index changes are flushed to disk
- * @param waitSearcher block until a new searcher is opened and registered as the
- * main query searcher, making the changes visible
+ * <p>Be very careful when triggering commits from the client side. Commits are heavy operations
+ * and WILL impact Solr performance when executed too often or too close together. Instead,
+ * consider using 'commitWithin' when adding documents or rely on your core's/collection's
+ * 'autoCommit' settings.
*
+ * @param waitFlush block until index changes are flushed to disk
+ * @param waitSearcher block until a new searcher is opened and registered as the main query
+ * searcher, making the changes visible
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse commit(boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException {
+ public UpdateResponse commit(boolean waitFlush, boolean waitSearcher)
+ throws SolrServerException, IOException {
return commit(null, waitFlush, waitSearcher);
}
/**
* Performs an explicit commit, causing pending documents to be committed for indexing
*
- * Be very careful when triggering commits from the client side. Commits are heavy operations and WILL impact Solr
- * performance when executed too often or too close together. Instead, consider using 'commitWithin' when adding documents
- * or rely on your core's/collection's 'autoCommit' settings.
+ * <p>Be very careful when triggering commits from the client side. Commits are heavy operations
+ * and WILL impact Solr performance when executed too often or too close together. Instead,
+ * consider using 'commitWithin' when adding documents or rely on your core's/collection's
+ * 'autoCommit' settings.
*
* @param collection the Solr collection to send the commit to
- * @param waitFlush block until index changes are flushed to disk
- * @param waitSearcher block until a new searcher is opened and registered as the
- * main query searcher, making the changes visible
- * @param softCommit makes index changes visible while neither fsync-ing index files
- * nor writing a new index descriptor
- *
+ * @param waitFlush block until index changes are flushed to disk
+ * @param waitSearcher block until a new searcher is opened and registered as the main query
+ * searcher, making the changes visible
+ * @param softCommit makes index changes visible while neither fsync-ing index files nor writing a
+ * new index descriptor
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse commit(String collection, boolean waitFlush, boolean waitSearcher, boolean softCommit)
+ public UpdateResponse commit(
+ String collection, boolean waitFlush, boolean waitSearcher, boolean softCommit)
throws SolrServerException, IOException {
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.COMMIT, waitFlush, waitSearcher, softCommit)
@@ -556,19 +517,18 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs an explicit commit, causing pending documents to be committed for indexing
*
- * Be very careful when triggering commits from the client side. Commits are heavy operations and WILL impact Solr
- * performance when executed too often or too close together. Instead, consider using 'commitWithin' when adding documents
- * or rely on your core's/collection's 'autoCommit' settings.
- *
- * @param waitFlush block until index changes are flushed to disk
- * @param waitSearcher block until a new searcher is opened and registered as the
- * main query searcher, making the changes visible
- * @param softCommit makes index changes visible while neither fsync-ing index files
- * nor writing a new index descriptor
+ * <p>Be very careful when triggering commits from the client side. Commits are heavy operations
+ * and WILL impact Solr performance when executed too often or too close together. Instead,
+ * consider using 'commitWithin' when adding documents or rely on your core's/collection's
+ * 'autoCommit' settings.
*
+ * @param waitFlush block until index changes are flushed to disk
+ * @param waitSearcher block until a new searcher is opened and registered as the main query
+ * searcher, making the changes visible
+ * @param softCommit makes index changes visible while neither fsync-ing index files nor writing a
+ * new index descriptor
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -580,15 +540,13 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs an explicit optimize, causing a merge of all segments to one.
*
- * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
+ * <p>waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
*
- * Note: In most cases it is not required to do explicit optimize
+ * <p>Note: In most cases it is not required to do explicit optimize
*
* @param collection the Solr collection to send the optimize to
- *
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -599,13 +557,12 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs an explicit optimize, causing a merge of all segments to one.
*
- * waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
+ * <p>waitFlush=true and waitSearcher=true to be inline with the defaults for plain HTTP access
*
- * Note: In most cases it is not required to do explicit optimize
+ * <p>Note: In most cases it is not required to do explicit optimize
*
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -615,61 +572,58 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs an explicit optimize, causing a merge of all segments to one.
- * <p>
- * Note: In most cases it is not required to do explicit optimize
*
- * @param collection the Solr collection to send the optimize to
- * @param waitFlush block until index changes are flushed to disk
- * @param waitSearcher block until a new searcher is opened and registered as
- * the main query searcher, making the changes visible
+ * <p>Note: In most cases it is not required to do explicit optimize
*
+ * @param collection the Solr collection to send the optimize to
+ * @param waitFlush block until index changes are flushed to disk
+ * @param waitSearcher block until a new searcher is opened and registered as the main query
+ * searcher, making the changes visible
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse optimize(String collection, boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException {
+ public UpdateResponse optimize(String collection, boolean waitFlush, boolean waitSearcher)
+ throws SolrServerException, IOException {
return optimize(collection, waitFlush, waitSearcher, 1);
}
/**
* Performs an explicit optimize, causing a merge of all segments to one.
- * <p>
- * Note: In most cases it is not required to do explicit optimize
*
- * @param waitFlush block until index changes are flushed to disk
- * @param waitSearcher block until a new searcher is opened and registered as
- * the main query searcher, making the changes visible
+ * <p>Note: In most cases it is not required to do explicit optimize
*
+ * @param waitFlush block until index changes are flushed to disk
+ * @param waitSearcher block until a new searcher is opened and registered as the main query
+ * searcher, making the changes visible
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher) throws SolrServerException, IOException {
+ public UpdateResponse optimize(boolean waitFlush, boolean waitSearcher)
+ throws SolrServerException, IOException {
return optimize(null, waitFlush, waitSearcher);
}
/**
* Performs an explicit optimize, causing a merge of all segments to one.
*
- * Note: In most cases it is not required to do explicit optimize
+ * <p>Note: In most cases it is not required to do explicit optimize
*
* @param collection the Solr collection to send the optimize to
- * @param waitFlush block until index changes are flushed to disk
- * @param waitSearcher block until a new searcher is opened and registered as
- * the main query searcher, making the changes visible
- * @param maxSegments optimizes down to at most this number of segments
- *
+ * @param waitFlush block until index changes are flushed to disk
+ * @param waitSearcher block until a new searcher is opened and registered as the main query
+ * searcher, making the changes visible
+ * @param maxSegments optimizes down to at most this number of segments
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse optimize(String collection, boolean waitFlush, boolean waitSearcher, int maxSegments)
+ public UpdateResponse optimize(
+ String collection, boolean waitFlush, boolean waitSearcher, int maxSegments)
throws SolrServerException, IOException {
return new UpdateRequest()
.setAction(UpdateRequest.ACTION.OPTIMIZE, waitFlush, waitSearcher, maxSegments)
@@ -679,16 +633,14 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs an explicit optimize, causing a merge of all segments to one.
*
- * Note: In most cases it is not required to do explicit optimize
- *
- * @param waitFlush block until index changes are flushed to disk
- * @param waitSearcher block until a new searcher is opened and registered as
- * the main query searcher, making the changes visible
- * @param maxSegments optimizes down to at most this number of segments
+ * <p>Note: In most cases it is not required to do explicit optimize
*
+ * @param waitFlush block until index changes are flushed to disk
+ * @param waitSearcher block until a new searcher is opened and registered as the main query
+ * searcher, making the changes visible
+ * @param maxSegments optimizes down to at most this number of segments
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -700,18 +652,15 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs a rollback of all non-committed documents pending.
*
- * Note that this is not a true rollback as in databases. Content you have previously
- * added may have been committed due to autoCommit, buffer full, other client performing
- * a commit etc.
- * <p>
- * Also note that rollbacks reset changes made by <i>all</i> clients. Use this method carefully when multiple clients,
- * or multithreaded clients are in use.
+ * <p>Note that this is not a true rollback as in databases. Content you have previously added may
+ * have been committed due to autoCommit, buffer full, other client performing a commit etc.
*
- * @param collection the Solr collection to send the rollback to
+ * <p>Also note that rollbacks reset changes made by <i>all</i> clients. Use this method carefully
+ * when multiple clients, or multithreaded clients are in use.
*
+ * @param collection the Solr collection to send the rollback to
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -722,16 +671,14 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Performs a rollback of all non-committed documents pending.
*
- * Note that this is not a true rollback as in databases. Content you have previously
- * added may have been committed due to autoCommit, buffer full, other client performing
- * a commit etc.
- * <p>
- * Also note that rollbacks reset changes made by <i>all</i> clients. Use this method carefully when multiple clients,
- * or multithreaded clients are in use.
+ * <p>Note that this is not a true rollback as in databases. Content you have previously added may
+ * have been committed due to autoCommit, buffer full, other client performing a commit etc.
*
- * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
+ * <p>Also note that rollbacks reset changes made by <i>all</i> clients. Use this method carefully
+ * when multiple clients, or multithreaded clients are in use.
*
+ * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -740,29 +687,26 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Deletes a single document by unique ID. Doesn't work for child/nested docs.
+ * Deletes a single document by unique ID. Doesn't work for child/nested docs.
*
* @param collection the Solr collection to delete the document from
- * @param id the ID of the document to delete
- *
+ * @param id the ID of the document to delete
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse deleteById(String collection, String id) throws SolrServerException, IOException {
+ public UpdateResponse deleteById(String collection, String id)
+ throws SolrServerException, IOException {
return deleteById(collection, id, -1);
}
/**
- * Deletes a single document by unique ID. Doesn't work for child/nested docs.
- *
- * @param id the ID of the document to delete
+ * Deletes a single document by unique ID. Doesn't work for child/nested docs.
*
+ * @param id the ID of the document to delete
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -771,22 +715,20 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Deletes a single document by unique ID, specifying max time before commit.
- * Doesn't work for child/nested docs.
+ * Deletes a single document by unique ID, specifying max time before commit. Doesn't work for
+ * child/nested docs.
*
* @param collection the Solr collection to delete the document from
- * @param id the ID of the document to delete
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param id the ID of the document to delete
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
- *
* @since 5.1
*/
- public UpdateResponse deleteById(String collection, String id, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse deleteById(String collection, String id, int commitWithinMs)
+ throws SolrServerException, IOException {
UpdateRequest req = new UpdateRequest();
req.deleteById(id);
req.setCommitWithin(commitWithinMs);
@@ -794,48 +736,43 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Deletes a single document by unique ID, specifying max time before commit.
- * Doesn't work for child/nested docs.
- *
- * @param id the ID of the document to delete
- * @param commitWithinMs max time (in ms) before a commit will happen
+ * Deletes a single document by unique ID, specifying max time before commit. Doesn't work for
+ * child/nested docs.
*
+ * @param id the ID of the document to delete
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
- *
* @since 3.6
*/
- public UpdateResponse deleteById(String id, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse deleteById(String id, int commitWithinMs)
+ throws SolrServerException, IOException {
return deleteById(null, id, commitWithinMs);
}
/**
- * Deletes a list of documents by unique ID. Doesn't work for child/nested docs.
+ * Deletes a list of documents by unique ID. Doesn't work for child/nested docs.
*
* @param collection the Solr collection to delete the documents from
- * @param ids the list of document IDs to delete; must be non-null and contain elements
- *
+ * @param ids the list of document IDs to delete; must be non-null and contain elements
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse deleteById(String collection, List<String> ids) throws SolrServerException, IOException {
+ public UpdateResponse deleteById(String collection, List<String> ids)
+ throws SolrServerException, IOException {
return deleteById(collection, ids, -1);
}
/**
- * Deletes a list of documents by unique ID. Doesn't work for child/nested docs.
- *
- * @param ids the list of document IDs to delete; must be non-null and contain elements
+ * Deletes a list of documents by unique ID. Doesn't work for child/nested docs.
*
+ * @param ids the list of document IDs to delete; must be non-null and contain elements
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -844,24 +781,24 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Deletes a list of documents by unique ID, specifying max time before commit.
- * Doesn't work for child/nested docs.
+ * Deletes a list of documents by unique ID, specifying max time before commit. Doesn't work for
+ * child/nested docs.
*
* @param collection the Solr collection to delete the documents from
- * @param ids the list of document IDs to delete; must be non-null and contain elements
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param ids the list of document IDs to delete; must be non-null and contain elements
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
- *
* @since 5.1
*/
- public UpdateResponse deleteById(String collection, List<String> ids, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse deleteById(String collection, List<String> ids, int commitWithinMs)
+ throws SolrServerException, IOException {
if (ids == null) throw new IllegalArgumentException("'ids' parameter must be non-null");
- if (ids.isEmpty()) throw new IllegalArgumentException("'ids' parameter must not be empty; should contain IDs to delete");
+ if (ids.isEmpty())
+ throw new IllegalArgumentException(
+ "'ids' parameter must not be empty; should contain IDs to delete");
UpdateRequest req = new UpdateRequest();
req.deleteById(ids);
@@ -870,21 +807,19 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Deletes a list of documents by unique ID, specifying max time before commit.
- * Doesn't work for child/nested docs.
- *
- * @param ids the list of document IDs to delete
- * @param commitWithinMs max time (in ms) before a commit will happen
+ * Deletes a list of documents by unique ID, specifying max time before commit. Doesn't work for
+ * child/nested docs.
*
+ * @param ids the list of document IDs to delete
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
- *
* @since 3.6
*/
- public UpdateResponse deleteById(List<String> ids, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse deleteById(List<String> ids, int commitWithinMs)
+ throws SolrServerException, IOException {
return deleteById(null, ids, commitWithinMs);
}
@@ -892,26 +827,23 @@ public abstract class SolrClient implements Serializable, Closeable {
* Deletes documents from the index based on a query
*
* @param collection the Solr collection to delete the documents from
- * @param query the query expressing what documents to delete
- *
+ * @param query the query expressing what documents to delete
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public UpdateResponse deleteByQuery(String collection, String query) throws SolrServerException, IOException {
+ public UpdateResponse deleteByQuery(String collection, String query)
+ throws SolrServerException, IOException {
return deleteByQuery(collection, query, -1);
}
/**
* Deletes documents from the index based on a query
*
- * @param query the query expressing what documents to delete
- *
+ * @param query the query expressing what documents to delete
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -923,18 +855,16 @@ public abstract class SolrClient implements Serializable, Closeable {
* Deletes documents from the index based on a query, specifying max time before commit
*
* @param collection the Solr collection to delete the documents from
- * @param query the query expressing what documents to delete
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param query the query expressing what documents to delete
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
- *
* @since 5.1
*/
- public UpdateResponse deleteByQuery(String collection, String query, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse deleteByQuery(String collection, String query, int commitWithinMs)
+ throws SolrServerException, IOException {
UpdateRequest req = new UpdateRequest();
req.deleteByQuery(query);
req.setCommitWithin(commitWithinMs);
@@ -944,18 +874,16 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Deletes documents from the index based on a query, specifying max time before commit
*
- * @param query the query expressing what documents to delete
- * @param commitWithinMs max time (in ms) before a commit will happen
- *
+ * @param query the query expressing what documents to delete
+ * @param commitWithinMs max time (in ms) before a commit will happen
* @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
- *
* @since 3.6
*/
- public UpdateResponse deleteByQuery(String query, int commitWithinMs) throws SolrServerException, IOException {
+ public UpdateResponse deleteByQuery(String query, int commitWithinMs)
+ throws SolrServerException, IOException {
return deleteByQuery(null, query, commitWithinMs);
}
@@ -963,10 +891,8 @@ public abstract class SolrClient implements Serializable, Closeable {
* Issues a ping request to check if the collection's replicas are alive
*
* @param collection collection to ping
- *
- * @return a {@link org.apache.solr.client.solrj.response.SolrPingResponse} containing the response
- * from the server
- *
+ * @return a {@link org.apache.solr.client.solrj.response.SolrPingResponse} containing the
+ * response from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -977,9 +903,8 @@ public abstract class SolrClient implements Serializable, Closeable {
/**
* Issues a ping request to check if the server is alive
*
- * @return a {@link org.apache.solr.client.solrj.response.SolrPingResponse} containing the response
- * from the server
- *
+ * @return a {@link org.apache.solr.client.solrj.response.SolrPingResponse} containing the
+ * response from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -987,31 +912,27 @@ public abstract class SolrClient implements Serializable, Closeable {
return new SolrPing().process(this, null);
}
-
/**
* Performs a query to the Solr server
*
* @param collection the Solr collection to query
- * @param params an object holding all key/value parameters to send along the request
- *
+ * @param params an object holding all key/value parameters to send along the request
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public QueryResponse query(String collection, SolrParams params) throws SolrServerException, IOException {
+ public QueryResponse query(String collection, SolrParams params)
+ throws SolrServerException, IOException {
return new QueryRequest(params).process(this, collection);
}
/**
* Performs a query to the Solr server
*
- * @param params an object holding all key/value parameters to send along the request
- *
+ * @param params an object holding all key/value parameters to send along the request
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -1023,67 +944,65 @@ public abstract class SolrClient implements Serializable, Closeable {
* Performs a query to the Solr server
*
* @param collection the Solr collection to query
- * @param params an object holding all key/value parameters to send along the request
- * @param method specifies the HTTP method to use for the request, such as GET or POST
- *
+ * @param params an object holding all key/value parameters to send along the request
+ * @param method specifies the HTTP method to use for the request, such as GET or POST
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public QueryResponse query(String collection, SolrParams params, METHOD method) throws SolrServerException, IOException {
+ public QueryResponse query(String collection, SolrParams params, METHOD method)
+ throws SolrServerException, IOException {
return new QueryRequest(params, method).process(this, collection);
}
/**
* Performs a query to the Solr server
*
- * @param params an object holding all key/value parameters to send along the request
- * @param method specifies the HTTP method to use for the request, such as GET or POST
- *
+ * @param params an object holding all key/value parameters to send along the request
+ * @param method specifies the HTTP method to use for the request, such as GET or POST
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public QueryResponse query(SolrParams params, METHOD method) throws SolrServerException, IOException {
+ public QueryResponse query(SolrParams params, METHOD method)
+ throws SolrServerException, IOException {
return query(null, params, method);
}
/**
- * Query solr, and stream the results. Unlike the standard query, this will
- * send events for each Document rather then add them to the QueryResponse.
+ * Query solr, and stream the results. Unlike the standard query, this will send events for each
+ * Document rather then add them to the QueryResponse.
*
- * Although this function returns a 'QueryResponse' it should be used with care
- * since it excludes anything that was passed to callback. Also note that
- * future version may pass even more info to the callback and may not return
- * the results in the QueryResponse.
+ * <p>Although this function returns a 'QueryResponse' it should be used with care since it
+ * excludes anything that was passed to callback. Also note that future version may pass even more
+ * info to the callback and may not return the results in the QueryResponse.
*
* @param collection the Solr collection to query
- * @param params an object holding all key/value parameters to send along the request
+ * @param params an object holding all key/value parameters to send along the request
* @param callback the callback to stream results to
- *
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
- *
* @since solr 5.1
*/
- public QueryResponse queryAndStreamResponse(String collection, SolrParams params, StreamingResponseCallback callback)
+ public QueryResponse queryAndStreamResponse(
+ String collection, SolrParams params, StreamingResponseCallback callback)
throws SolrServerException, IOException {
- return getQueryResponse(collection, params, new StreamingBinaryResponseParser(callback));
+ return getQueryResponse(collection, params, new StreamingBinaryResponseParser(callback));
}
- public QueryResponse queryAndStreamResponse(String collection, SolrParams params, FastStreamingDocsCallback callback)
+ public QueryResponse queryAndStreamResponse(
+ String collection, SolrParams params, FastStreamingDocsCallback callback)
throws SolrServerException, IOException {
return getQueryResponse(collection, params, new StreamingBinaryResponseParser(callback));
}
- private QueryResponse getQueryResponse(String collection, SolrParams params, ResponseParser parser) throws SolrServerException, IOException {
+ private QueryResponse getQueryResponse(
+ String collection, SolrParams params, ResponseParser parser)
+ throws SolrServerException, IOException {
QueryRequest req = new QueryRequest(params);
if (parser instanceof StreamingBinaryResponseParser) {
req.setStreamingResponseCallback(((StreamingBinaryResponseParser) parser).callback);
@@ -1093,23 +1012,19 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Query solr, and stream the results. Unlike the standard query, this will
- * send events for each Document rather then add them to the QueryResponse.
+ * Query solr, and stream the results. Unlike the standard query, this will send events for each
+ * Document rather then add them to the QueryResponse.
*
- * Although this function returns a 'QueryResponse' it should be used with care
- * since it excludes anything that was passed to callback. Also note that
- * future version may pass even more info to the callback and may not return
- * the results in the QueryResponse.
+ * <p>Although this function returns a 'QueryResponse' it should be used with care since it
+ * excludes anything that was passed to callback. Also note that future version may pass even more
+ * info to the callback and may not return the results in the QueryResponse.
*
- * @param params an object holding all key/value parameters to send along the request
+ * @param params an object holding all key/value parameters to send along the request
* @param callback the callback to stream results to
- *
* @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response
- * from the server
- *
+ * from the server
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
- *
* @since solr 4.0
*/
public QueryResponse queryAndStreamResponse(SolrParams params, StreamingResponseCallback callback)
@@ -1122,22 +1037,19 @@ public abstract class SolrClient implements Serializable, Closeable {
*
* @param collection the Solr collection to query
* @param id the id
- *
* @return retrieved SolrDocument, or null if no document is found.
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public SolrDocument getById(String collection, String id) throws SolrServerException, IOException {
+ public SolrDocument getById(String collection, String id)
+ throws SolrServerException, IOException {
return getById(collection, id, null);
}
/**
* Retrieves the SolrDocument associated with the given identifier.
*
* @param id the id
- *
* @return retrieved SolrDocument, or null if no document is found.
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -1146,19 +1058,18 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Retrieves the SolrDocument associated with the given identifier and uses
- * the SolrParams to execute the request.
+ * Retrieves the SolrDocument associated with the given identifier and uses the SolrParams to
+ * execute the request.
*
* @param collection the Solr collection to query
* @param id the id
* @param params additional parameters to add to the query
- *
* @return retrieved SolrDocument, or null if no document is found.
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public SolrDocument getById(String collection, String id, SolrParams params) throws SolrServerException, IOException {
+ public SolrDocument getById(String collection, String id, SolrParams params)
+ throws SolrServerException, IOException {
SolrDocumentList docs = getById(collection, Collections.singletonList(id), params);
if (!docs.isEmpty()) {
return docs.get(0);
@@ -1167,48 +1078,44 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Retrieves the SolrDocument associated with the given identifier and uses
- * the SolrParams to execute the request.
+ * Retrieves the SolrDocument associated with the given identifier and uses the SolrParams to
+ * execute the request.
*
* @param id the id
* @param params additional parameters to add to the query
- *
* @return retrieved SolrDocument, or null if no document is found.
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public SolrDocument getById(String id, SolrParams params) throws SolrServerException, IOException {
+ public SolrDocument getById(String id, SolrParams params)
+ throws SolrServerException, IOException {
return getById(null, id, params);
}
/**
* Retrieves the SolrDocuments associated with the given identifiers.
*
- * If a document was not found, it will not be added to the SolrDocumentList.
+ * <p>If a document was not found, it will not be added to the SolrDocumentList.
*
* @param collection the Solr collection to query
* @param ids the ids
- *
* @return a SolrDocumentList, or null if no documents were found
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public SolrDocumentList getById(String collection, Collection<String> ids) throws SolrServerException, IOException {
+ public SolrDocumentList getById(String collection, Collection<String> ids)
+ throws SolrServerException, IOException {
return getById(collection, ids, null);
}
/**
* Retrieves the SolrDocuments associated with the given identifiers.
*
- * If a document was not found, it will not be added to the SolrDocumentList.
+ * <p>If a document was not found, it will not be added to the SolrDocumentList.
*
* @param ids the ids
- *
* @return a SolrDocumentList, or null if no documents were found
- *
- * @throws IOException If there is a low-level I/O error.
+ * @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
public SolrDocumentList getById(Collection<String> ids) throws SolrServerException, IOException {
@@ -1216,17 +1123,15 @@ public abstract class SolrClient implements Serializable, Closeable {
}
/**
- * Retrieves the SolrDocuments associated with the given identifiers and uses
- * the SolrParams to execute the request.
+ * Retrieves the SolrDocuments associated with the given identifiers and uses the SolrParams to
+ * execute the request.
*
- * If a document was not found, it will not be added to the SolrDocumentList.
+ * <p>If a document was not found, it will not be added to the SolrDocumentList.
*
* @param collection the Solr collection to query
* @param ids the ids
* @param params additional parameters to add to the query
- *
* @return a SolrDocumentList, or null if no documents were found
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -1240,25 +1145,26 @@ public abstract class SolrClient implements Serializable, Closeable {
if (StringUtils.isEmpty(reqParams.get(CommonParams.QT))) {
reqParams.set(CommonParams.QT, "/get");
}
- reqParams.set("ids", ids.stream().map(id -> StrUtils.escapeTextWithSeparator(id, ',')).toArray(String[]::new));
+ reqParams.set(
+ "ids",
+ ids.stream().map(id -> StrUtils.escapeTextWithSeparator(id, ',')).toArray(String[]::new));
return query(collection, reqParams).getResults();
}
/**
- * Retrieves the SolrDocuments associated with the given identifiers and uses
- * the SolrParams to execute the request.
+ * Retrieves the SolrDocuments associated with the given identifiers and uses the SolrParams to
+ * execute the request.
*
- * If a document was not found, it will not be added to the SolrDocumentList.
+ * <p>If a document was not found, it will not be added to the SolrDocumentList.
*
* @param ids the ids
* @param params additional parameters to add to the query
- *
* @return a SolrDocumentList, or null if no documents were found
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public SolrDocumentList getById(Collection<String> ids, SolrParams params) throws SolrServerException, IOException {
+ public SolrDocumentList getById(Collection<String> ids, SolrParams params)
+ throws SolrServerException, IOException {
return getById(null, ids, params);
}
@@ -1267,9 +1173,7 @@ public abstract class SolrClient implements Serializable, Closeable {
*
* @param request the request to execute
* @param collection the collection to execute the request against
- *
* @return a {@link NamedList} containing the response from the server
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
@@ -1280,13 +1184,12 @@ public abstract class SolrClient implements Serializable, Closeable {
* Execute a request against a Solr server
*
* @param request the request to execute
- *
* @return a {@link NamedList} containing the response from the server
- *
* @throws IOException If there is a low-level I/O error.
* @throws SolrServerException if there is an error on the server
*/
- public final NamedList<Object> request(final SolrRequest<?> request) throws SolrServerException, IOException {
+ public final NamedList<Object> request(final SolrRequest<?> request)
+ throws SolrServerException, IOException {
return request(request, null);
}
@@ -1294,21 +1197,20 @@ public abstract class SolrClient implements Serializable, Closeable {
* Get the {@link org.apache.solr.client.solrj.beans.DocumentObjectBinder} for this client.
*
* @return a DocumentObjectBinder
- *
* @see SolrClient#addBean
* @see SolrClient#addBeans
*/
public DocumentObjectBinder getBinder() {
- if(binder == null){
+ if (binder == null) {
binder = new DocumentObjectBinder();
}
return binder;
}
/**
- * This method defines the context in which this Solr client
- * is being used (e.g. for internal communication between Solr
- * nodes or as an external client). The default value is {@code SolrClientContext#Client}
+ * This method defines the context in which this Solr client is being used (e.g. for internal
+ * communication between Solr nodes or as an external client). The default value is {@code
+ * SolrClientContext#Client}
*/
public SolrRequest.SolrClientContext getContext() {
return SolrRequest.SolrClientContext.CLIENT;
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrQuery.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrQuery.java
index 60e6ae3..d43c93d 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrQuery.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrQuery.java
@@ -22,7 +22,6 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.regex.Pattern;
-
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.HighlightParams;
@@ -31,19 +30,21 @@ import org.apache.solr.common.params.MoreLikeThisParams;
import org.apache.solr.common.params.StatsParams;
import org.apache.solr.common.params.TermsParams;
-
/**
- * This is an augmented SolrParams with get/set/add fields for common fields used
- * in the Standard and Dismax request handlers
- *
+ * This is an augmented SolrParams with get/set/add fields for common fields used in the Standard
+ * and Dismax request handlers
*
* @since solr 1.3
*/
-public class SolrQuery extends ModifiableSolrParams
-{
- public static final String DOCID = "_docid_"; // duplicate of org.apache.solr.search.SortSpecParsing.DOCID which is not accessible from here
-
- public enum ORDER { desc, asc;
+public class SolrQuery extends ModifiableSolrParams {
+ // duplicate of org.apache.solr.search.SortSpecParsing.DOCID which is not
+ // accessible from here
+ public static final String DOCID = "_docid_";
+
+ public enum ORDER {
+ desc,
+ asc;
+
public ORDER reverse() {
return (this == asc) ? desc : asc;
}
@@ -51,13 +52,14 @@ public class SolrQuery extends ModifiableSolrParams
/** Maintains a map of current sorts */
private List<SortClause> sortClauses;
-
+
public SolrQuery() {
super();
}
- /** Create a new SolrQuery
- *
+ /**
+ * Create a new SolrQuery
+ *
* @param q query string
*/
public SolrQuery(String q) {
@@ -73,9 +75,11 @@ public class SolrQuery extends ModifiableSolrParams
}
}
- /** enable/disable terms.
- *
- * @param b flag to indicate terms should be enabled. <br> if b==false, removes all other terms parameters
+ /**
+ * enable/disable terms.
+ *
+ * @param b flag to indicate terms should be enabled. <br>
+ * if b==false, removes all other terms parameters
* @return Current reference (<i>this</i>)
*/
public SolrQuery setTerms(boolean b) {
@@ -99,70 +103,70 @@ public class SolrQuery extends ModifiableSolrParams
}
return this;
}
-
+
public boolean getTerms() {
return this.getBool(TermsParams.TERMS, false);
}
-
+
public SolrQuery addTermsField(String field) {
this.add(TermsParams.TERMS_FIELD, field);
return this;
}
-
+
public String[] getTermsFields() {
return this.getParams(TermsParams.TERMS_FIELD);
}
-
+
public SolrQuery setTermsLower(String lower) {
this.set(TermsParams.TERMS_LOWER, lower);
return this;
}
-
+
public String getTermsLower() {
return this.get(TermsParams.TERMS_LOWER, "");
}
-
+
public SolrQuery setTermsUpper(String upper) {
this.set(TermsParams.TERMS_UPPER, upper);
return this;
}
-
+
public String getTermsUpper() {
return this.get(TermsParams.TERMS_UPPER, "");
}
-
+
public SolrQuery setTermsUpperInclusive(boolean b) {
this.set(TermsParams.TERMS_UPPER_INCLUSIVE, b);
return this;
}
-
+
public boolean getTermsUpperInclusive() {
return this.getBool(TermsParams.TERMS_UPPER_INCLUSIVE, false);
}
-
+
public SolrQuery setTermsLowerInclusive(boolean b) {
this.set(TermsParams.TERMS_LOWER_INCLUSIVE, b);
return this;
}
-
+
public boolean getTermsLowerInclusive() {
return this.getBool(TermsParams.TERMS_LOWER_INCLUSIVE, true);
}
-
+
public SolrQuery setTermsLimit(int limit) {
this.set(TermsParams.TERMS_LIMIT, limit);
return this;
}
-
+
public int getTermsLimit() {
return this.getInt(TermsParams.TERMS_LIMIT, 10);
}
-
+
public SolrQuery setTermsMinCount(int cnt) {
this.set(TermsParams.TERMS_MINCOUNT, cnt);
return this;
}
-
+
public int getTermsMinCount() {
return this.getInt(TermsParams.TERMS_MINCOUNT, 1);
}
@@ -171,39 +175,39 @@ public class SolrQuery extends ModifiableSolrParams
this.set(TermsParams.TERMS_MAXCOUNT, cnt);
return this;
}
-
+
public int getTermsMaxCount() {
return this.getInt(TermsParams.TERMS_MAXCOUNT, -1);
}
-
+
public SolrQuery setTermsPrefix(String prefix) {
this.set(TermsParams.TERMS_PREFIX_STR, prefix);
return this;
}
-
+
public String getTermsPrefix() {
return this.get(TermsParams.TERMS_PREFIX_STR, "");
}
-
+
public SolrQuery setTermsRaw(boolean b) {
this.set(TermsParams.TERMS_RAW, b);
return this;
}
-
+
public boolean getTermsRaw() {
return this.getBool(TermsParams.TERMS_RAW, false);
}
-
+
public SolrQuery setTermsSortString(String type) {
this.set(TermsParams.TERMS_SORT, type);
return this;
}
-
+
public String getTermsSortString() {
return this.get(TermsParams.TERMS_SORT, TermsParams.TERMS_SORT_COUNT);
}
- public SolrQuery setTermsRegex(String regex) {
+ public SolrQuery setTermsRegex(String regex) {
this.set(TermsParams.TERMS_REGEXP_STR, regex);
return this;
}
@@ -217,29 +221,31 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- public String[] getTermsRegexFlags() {
+ public String[] getTermsRegexFlags() {
return this.getParams(TermsParams.TERMS_REGEXP_FLAG);
}
-
- /** Add field(s) for facet computation.
- *
+
+ /**
+ * Add field(s) for facet computation.
+ *
* @param fields Array of field names from the IndexSchema
* @return this
*/
- public SolrQuery addFacetField(String ... fields) {
+ public SolrQuery addFacetField(String... fields) {
add(FacetParams.FACET_FIELD, fields);
this.set(FacetParams.FACET, true);
return this;
}
- /** Add field(s) for pivot computation.
- *
- * pivot fields are comma separated
- *
+ /**
+ * Add field(s) for pivot computation.
+ *
+ * <p>pivot fields are comma separated
+ *
* @param fields Array of field names from the IndexSchema
* @return this
*/
- public SolrQuery addFacetPivotField(String ... fields) {
+ public SolrQuery addFacetPivotField(String... fields) {
add(FacetParams.FACET_PIVOT, fields);
this.set(FacetParams.FACET, true);
return this;
@@ -256,7 +262,9 @@ public class SolrQuery extends ModifiableSolrParams
*/
public SolrQuery addNumericRangeFacet(String field, Number start, Number end, Number gap) {
add(FacetParams.FACET_RANGE, field);
- add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_START), start.toString());
+ add(
+ String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_START),
+ start.toString());
add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_END), end.toString());
add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_GAP), gap.toString());
this.set(FacetParams.FACET, true);
@@ -274,26 +282,28 @@ public class SolrQuery extends ModifiableSolrParams
*/
public SolrQuery addDateRangeFacet(String field, Date start, Date end, String gap) {
add(FacetParams.FACET_RANGE, field);
- add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_START), start.toInstant().toString());
- add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_END), end.toInstant().toString());
- add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_GAP), gap);
+ add(
+ String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_START),
+ start.toInstant().toString());
+ add(
+ String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_END),
+ end.toInstant().toString());
+ add(String.format(Locale.ROOT, "f.%s.%s", field, FacetParams.FACET_RANGE_GAP), gap);
this.set(FacetParams.FACET, true);
return this;
}
/**
- * Add Interval Faceting on a field. All intervals for the same field should be included
- * in the same call to this method.
- * For syntax documentation see <a href="https://solr.apache.org/guide/faceting.html#interval-faceting">Solr wiki</a>.
- * <br>
- * Key substitution, filter exclusions or other local params on the field are not supported when using this method,
- * if this is needed, use the lower level {@link #add} method.<br>
+ * Add Interval Faceting on a field. All intervals for the same field should be included in the
+ * same call to this method. For syntax documentation see <a
+ * href="https://solr.apache.org/guide/faceting.html#interval-faceting">Solr wiki</a>. <br>
+ * Key substitution, filter exclusions or other local params on the field are not supported when
+ * using this method, if this is needed, use the lower level {@link #add} method.<br>
* Key substitution IS supported on intervals when using this method.
*
- *
* @param field the field to add facet intervals. Must be an existing field and can't be null
- * @param intervals Intervals to be used for faceting. It can be an empty array, but it can't
- * be <code>null</code>
+ * @param intervals Intervals to be used for faceting. It can be an empty array, but it can't be
+ * <code>null</code>
* @return this
*/
public SolrQuery addIntervalFacets(String field, String[] intervals) {
@@ -305,37 +315,39 @@ public class SolrQuery extends ModifiableSolrParams
}
set(FacetParams.FACET, true);
add(FacetParams.FACET_INTERVAL, field);
- for (String interval:intervals) {
+ for (String interval : intervals) {
add(String.format(Locale.ROOT, "f.%s.facet.interval.set", field), interval);
}
return this;
}
-
+
/**
* Remove all Interval Facets on a field
- *
+ *
* @param field the field to remove from facet intervals
* @return Array of current intervals for <code>field</code>
*/
public String[] removeIntervalFacets(String field) {
- while(remove(FacetParams.FACET_INTERVAL, field)){};
+ while (remove(FacetParams.FACET_INTERVAL, field)) {}
+ ;
return remove(String.format(Locale.ROOT, "f.%s.facet.interval.set", field));
}
-
- /** get the facet fields
- *
+
+ /**
+ * get the facet fields
+ *
* @return string array of facet fields or null if not set/empty
*/
public String[] getFacetFields() {
return this.getParams(FacetParams.FACET_FIELD);
}
- /** remove a facet field
- *
+ /**
+ * remove a facet field
+ *
* @param name Name of the facet field to be removed.
- *
* @return true, if the item was removed. <br>
- * false, if the facet field was null or did not exist.
+ * false, if the facet field was null or did not exist.
*/
public boolean removeFacetField(String name) {
boolean b = this.remove(FacetParams.FACET_FIELD, name);
@@ -344,10 +356,12 @@ public class SolrQuery extends ModifiableSolrParams
}
return b;
}
-
- /** enable/disable faceting.
- *
- * @param b flag to indicate faceting should be enabled. <br> if b==false, removes all other faceting parameters
+
+ /**
+ * enable/disable faceting.
+ *
+ * @param b flag to indicate faceting should be enabled. <br>
+ * if b==false, removes all other faceting parameters
* @return Current reference (<i>this</i>)
*/
public SolrQuery setFacet(boolean b) {
@@ -369,21 +383,20 @@ public class SolrQuery extends ModifiableSolrParams
}
return this;
}
-
- public SolrQuery setFacetPrefix( String prefix )
- {
- this.set( FacetParams.FACET_PREFIX, prefix );
+
+ public SolrQuery setFacetPrefix(String prefix) {
+ this.set(FacetParams.FACET_PREFIX, prefix);
return this;
}
- public SolrQuery setFacetPrefix( String field, String prefix )
- {
- this.set( "f."+field+"."+FacetParams.FACET_PREFIX, prefix );
+ public SolrQuery setFacetPrefix(String field, String prefix) {
+ this.set("f." + field + "." + FacetParams.FACET_PREFIX, prefix);
return this;
}
- /** add a faceting query
- *
+ /**
+ * add a faceting query
+ *
* @param f facet query
*/
public SolrQuery addFacetQuery(String f) {
@@ -392,16 +405,18 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /** get facet queries
- *
+ /**
+ * get facet queries
+ *
* @return all facet queries or null if not set/empty
*/
public String[] getFacetQuery() {
return this.getParams(FacetParams.FACET_QUERY);
}
- /** remove a facet query
- *
+ /**
+ * remove a facet query
+ *
* @param q the facet query to remove
* @return true if the facet query was removed false otherwise
*/
@@ -413,8 +428,9 @@ public class SolrQuery extends ModifiableSolrParams
return b;
}
- /** set the facet limit
- *
+ /**
+ * set the facet limit
+ *
* @param lim number facet items to return
*/
public SolrQuery setFacetLimit(int lim) {
@@ -422,16 +438,18 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /** get current facet limit
- *
+ /**
+ * get current facet limit
+ *
* @return facet limit or default of 25
*/
public int getFacetLimit() {
return this.getInt(FacetParams.FACET_LIMIT, 25);
}
- /** set facet minimum count
- *
+ /**
+ * set facet minimum count
+ *
* @param cnt facets having less that cnt hits will be excluded from teh facet list
*/
public SolrQuery setFacetMinCount(int cnt) {
@@ -439,8 +457,9 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /** get facet minimum count
- *
+ /**
+ * get facet minimum count
+ *
* @return facet minimum count or default of 1
*/
public int getFacetMinCount() {
@@ -448,9 +467,9 @@ public class SolrQuery extends ModifiableSolrParams
}
/**
- * Sets facet missing boolean flag
- *
- * @param v flag to indicate the field of {@link FacetParams#FACET_MISSING} .
+ * Sets facet missing boolean flag
+ *
+ * @param v flag to indicate the field of {@link FacetParams#FACET_MISSING} .
* @return this
*/
public SolrQuery setFacetMissing(Boolean v) {
@@ -458,17 +477,18 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /** get facet sort
- *
+ /**
+ * get facet sort
+ *
* @return facet sort or default of {@link FacetParams#FACET_SORT_COUNT}
*/
public String getFacetSortString() {
return this.get(FacetParams.FACET_SORT, FacetParams.FACET_SORT_COUNT);
}
-
- /** set facet sort
- *
+ /**
+ * set facet sort
+ *
* @param sort sort facets
* @return this
*/
@@ -477,8 +497,9 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /** add highlight field
- *
+ /**
+ * add highlight field
+ *
* @param f field to enable for highlighting
*/
public SolrQuery addHighlightField(String f) {
@@ -487,10 +508,12 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /** remove a field for highlighting
- *
+ /**
+ * remove a field for highlighting
+ *
* @param f field name to not highlight
- * @return <i>true</i>, if removed, <br> <i>false</i>, otherwise
+ * @return <i>true</i>, if removed, <br>
+ * <i>false</i>, otherwise
*/
public boolean removeHighlightField(String f) {
boolean b = this.remove(HighlightParams.FIELDS, f);
@@ -500,8 +523,9 @@ public class SolrQuery extends ModifiableSolrParams
return b;
}
- /** get list of highlighted fields
- *
+ /**
+ * get list of highlighted fields
+ *
* @return Array of highlight fields or null if not set/empty
*/
public String[] getHighlightFields() {
@@ -555,17 +579,16 @@ public class SolrQuery extends ModifiableSolrParams
/**
* Gets the raw sort field, as it will be sent to Solr.
- * <p>
- * The returned sort field will always contain a serialized version
- * of the sort string built using {@link #setSort(SortClause)},
- * {@link #addSort(SortClause)}, {@link #addOrUpdateSort(SortClause)},
- * {@link #removeSort(SortClause)}, {@link #clearSorts()} and
+ *
+ * <p>The returned sort field will always contain a serialized version of the sort string built
+ * using {@link #setSort(SortClause)}, {@link #addSort(SortClause)}, {@link
+ * #addOrUpdateSort(SortClause)}, {@link #removeSort(SortClause)}, {@link #clearSorts()} and
* {@link #setSorts(List)}.
*/
public String getSortField() {
return this.get(CommonParams.SORT);
}
-
+
/**
* Clears current sort information.
*
@@ -646,10 +669,9 @@ public class SolrQuery extends ModifiableSolrParams
}
/**
- * Updates or adds a single sort clause to the query.
- * If the field is already used for sorting, the order
- * of the existing field is modified; otherwise, it is
- * added to the end.
+ * Updates or adds a single sort clause to the query. If the field is already used for sorting,
+ * the order of the existing field is modified; otherwise, it is added to the end.
+ *
* @return the modified SolrQuery object, for easy chaining
* @since 4.2
*/
@@ -658,17 +680,16 @@ public class SolrQuery extends ModifiableSolrParams
}
/**
- * Updates or adds a single sort field specification to the current sort
- * information. If the sort field already exist in the sort information map,
- * its position is unchanged and the sort order is set; if it does not exist,
- * it is appended at the end with the specified order..
+ * Updates or adds a single sort field specification to the current sort information. If the sort
+ * field already exist in the sort information map, its position is unchanged and the sort order
+ * is set; if it does not exist, it is appended at the end with the specified order..
*
* @return the modified SolrQuery object, for easy chaining
* @since 4.2
*/
public SolrQuery addOrUpdateSort(SortClause sortClause) {
if (sortClauses != null) {
- for (int index=0 ; index<sortClauses.size() ; index++) {
+ for (int index = 0; index < sortClauses.size(); index++) {
SortClause existing = sortClauses.get(index);
if (existing.getItem().equals(sortClause.getItem())) {
sortClauses.set(index, sortClause);
@@ -725,32 +746,26 @@ public class SolrQuery extends ModifiableSolrParams
}
}
- public void setGetFieldStatistics( boolean v )
- {
- this.set( StatsParams.STATS, v );
+ public void setGetFieldStatistics(boolean v) {
+ this.set(StatsParams.STATS, v);
}
-
- public void setGetFieldStatistics( String field )
- {
- this.set( StatsParams.STATS, true );
- this.add( StatsParams.STATS_FIELD, field );
+
+ public void setGetFieldStatistics(String field) {
+ this.set(StatsParams.STATS, true);
+ this.add(StatsParams.STATS_FIELD, field);
}
-
- public void addGetFieldStatistics( String ... field )
- {
- this.set( StatsParams.STATS, true );
- this.add( StatsParams.STATS_FIELD, field );
- }
-
- public void addStatsFieldFacets( String field, String ... facets )
- {
- if( field == null ) {
- this.add( StatsParams.STATS_FACET, facets );
- }
- else {
- for( String f : facets ) {
- this.add( "f."+field+"."+StatsParams.STATS_FACET, f );
+ public void addGetFieldStatistics(String... field) {
+ this.set(StatsParams.STATS, true);
+ this.add(StatsParams.STATS_FIELD, field);
+ }
+
+ public void addStatsFieldFacets(String field, String... facets) {
+ if (field == null) {
+ this.add(StatsParams.STATS_FACET, facets);
+ } else {
+ for (String f : facets) {
+ this.add("f." + field + "." + StatsParams.STATS_FACET, f);
}
}
}
@@ -759,16 +774,17 @@ public class SolrQuery extends ModifiableSolrParams
if (field == null) {
this.add(StatsParams.STATS_CALC_DISTINCT, Boolean.toString(calcDistinct));
} else {
- this.add("f." + field + "." + StatsParams.STATS_CALC_DISTINCT, Boolean.toString(calcDistinct));
+ this.add(
+ "f." + field + "." + StatsParams.STATS_CALC_DISTINCT, Boolean.toString(calcDistinct));
}
}
- public SolrQuery setFilterQueries(String ... fq) {
+ public SolrQuery setFilterQueries(String... fq) {
this.set(CommonParams.FQ, fq);
return this;
}
- public SolrQuery addFilterQuery(String ... fq) {
+ public SolrQuery addFilterQuery(String... fq) {
this.add(CommonParams.FQ, fq);
return this;
}
@@ -780,11 +796,11 @@ public class SolrQuery extends ModifiableSolrParams
public String[] getFilterQueries() {
return this.getParams(CommonParams.FQ);
}
-
+
public boolean getHighlight() {
return this.getBool(HighlightParams.HIGHLIGHT, false);
}
-
+
public SolrQuery setHighlight(boolean b) {
if (b) {
this.set(HighlightParams.HIGHLIGHT, true);
@@ -801,10 +817,8 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
-
/**
- * Add field for MoreLikeThis. Automatically
- * enables MoreLikeThis.
+ * Add field for MoreLikeThis. Automatically enables MoreLikeThis.
*
* @param field the names of the field to be added
* @return this
@@ -815,8 +829,8 @@ public class SolrQuery extends ModifiableSolrParams
}
public SolrQuery setMoreLikeThisFields(String... fields) {
- if( fields == null || fields.length == 0 ) {
- this.remove( MoreLikeThisParams.SIMILARITY_FIELDS );
+ if (fields == null || fields.length == 0) {
+ this.remove(MoreLikeThisParams.SIMILARITY_FIELDS);
this.setMoreLikeThis(false);
return this;
}
@@ -832,12 +846,10 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * @return an array with the fields used to compute similarity.
- */
+ /** @return an array with the fields used to compute similarity. */
public String[] getMoreLikeThisFields() {
String fl = this.get(MoreLikeThisParams.SIMILARITY_FIELDS);
- if(fl==null || fl.length()==0) {
+ if (fl == null || fl.length() == 0) {
return null;
}
return fl.split(",");
@@ -854,16 +866,14 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * Gets the frequency below which terms will be ignored in the source doc
- */
+ /** Gets the frequency below which terms will be ignored in the source doc */
public int getMoreLikeThisMinTermFreq() {
return this.getInt(MoreLikeThisParams.MIN_TERM_FREQ, 2);
}
/**
- * Sets the frequency at which words will be ignored which do not occur in
- * at least this many docs.
+ * Sets the frequency at which words will be ignored which do not occur in at least this many
+ * docs.
*
* @param mindf the minimum document frequency
* @return this
@@ -874,8 +884,8 @@ public class SolrQuery extends ModifiableSolrParams
}
/**
- * Gets the frequency at which words will be ignored which do not occur in
- * at least this many docs.
+ * Gets the frequency at which words will be ignored which do not occur in at least this many
+ * docs.
*/
public int getMoreLikeThisMinDocFreq() {
return this.getInt(MoreLikeThisParams.MIN_DOC_FREQ, 5);
@@ -892,9 +902,7 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * Gets the minimum word length below which words will be ignored.
- */
+ /** Gets the minimum word length below which words will be ignored. */
public int getMoreLikeThisMinWordLen() {
return this.getInt(MoreLikeThisParams.MIN_WORD_LEN, 0);
}
@@ -910,16 +918,13 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * Gets the maximum word length above which words will be ignored.
- */
+ /** Gets the maximum word length above which words will be ignored. */
public int getMoreLikeThisMaxWordLen() {
return this.getInt(MoreLikeThisParams.MAX_WORD_LEN, 0);
}
/**
- * Sets the maximum number of query terms that will be included in any
- * generated query.
+ * Sets the maximum number of query terms that will be included in any generated query.
*
* @param maxqt the maximum number of query terms
* @return this
@@ -929,17 +934,14 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * Gets the maximum number of query terms that will be included in any
- * generated query.
- */
+ /** Gets the maximum number of query terms that will be included in any generated query. */
public int getMoreLikeThisMaxQueryTerms() {
return this.getInt(MoreLikeThisParams.MAX_QUERY_TERMS, 25);
}
/**
- * Sets the maximum number of tokens to parse in each example doc field
- * that is not stored with TermVector support.
+ * Sets the maximum number of tokens to parse in each example doc field that is not stored with
+ * TermVector support.
*
* @param maxntp the maximum number of tokens to parse
* @return this
@@ -950,8 +952,8 @@ public class SolrQuery extends ModifiableSolrParams
}
/**
- * Gets the maximum number of tokens to parse in each example doc field
- * that is not stored with TermVector support.
+ * Gets the maximum number of tokens to parse in each example doc field that is not stored with
+ * TermVector support.
*/
public int getMoreLikeThisMaxTokensParsed() {
return this.getInt(MoreLikeThisParams.MAX_NUM_TOKENS_PARSED, 5000);
@@ -968,17 +970,15 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * Gets if the query will be boosted by the interesting term relevance.
- */
+ /** Gets if the query will be boosted by the interesting term relevance. */
public boolean getMoreLikeThisBoost() {
return this.getBool(MoreLikeThisParams.BOOST, false);
}
/**
- * Sets the query fields and their boosts using the same format as that
- * used in DisMaxQParserPlugin. These fields must also be added
- * using {@link #addMoreLikeThisField(String)}.
+ * Sets the query fields and their boosts using the same format as that used in
+ * DisMaxQParserPlugin. These fields must also be added using {@link
+ * #addMoreLikeThisField(String)}.
*
* @param qf the query fields
* @return this
@@ -988,9 +988,7 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * Gets the query fields and their boosts.
- */
+ /** Gets the query fields and their boosts. */
public String getMoreLikeThisQF() {
return this.get(MoreLikeThisParams.QF);
}
@@ -1006,24 +1004,21 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * Gets the number of similar documents to return for each result.
- */
+ /** Gets the number of similar documents to return for each result. */
public int getMoreLikeThisCount() {
return this.getInt(MoreLikeThisParams.DOC_COUNT, MoreLikeThisParams.DEFAULT_DOC_COUNT);
}
/**
- * Enable/Disable MoreLikeThis. After enabling MoreLikeThis, the fields
- * used for computing similarity must be specified calling
- * {@link #addMoreLikeThisField(String)}.
+ * Enable/Disable MoreLikeThis. After enabling MoreLikeThis, the fields used for computing
+ * similarity must be specified calling {@link #addMoreLikeThisField(String)}.
*
- * @param b flag to indicate if MoreLikeThis should be enabled. if b==false
- * removes all mlt.* parameters
+ * @param b flag to indicate if MoreLikeThis should be enabled. if b==false removes all mlt.*
+ * parameters
* @return this
*/
public SolrQuery setMoreLikeThis(boolean b) {
- if(b) {
+ if (b) {
this.set(MoreLikeThisParams.MLT, true);
} else {
this.remove(MoreLikeThisParams.MLT);
@@ -1041,35 +1036,33 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /**
- * @return true if MoreLikeThis is enabled, false otherwise
- */
+ /** @return true if MoreLikeThis is enabled, false otherwise */
public boolean getMoreLikeThis() {
return this.getBool(MoreLikeThisParams.MLT, false);
}
- public SolrQuery setFields(String ... fields) {
- if( fields == null || fields.length == 0 ) {
- this.remove( CommonParams.FL );
+ public SolrQuery setFields(String... fields) {
+ if (fields == null || fields.length == 0) {
+ this.remove(CommonParams.FL);
return this;
}
StringBuilder sb = new StringBuilder();
- sb.append( fields[0] );
- for( int i=1; i<fields.length; i++ ) {
- sb.append( ',' );
- sb.append( fields[i] );
+ sb.append(fields[0]);
+ for (int i = 1; i < fields.length; i++) {
+ sb.append(',');
+ sb.append(fields[i]);
}
- this.set(CommonParams.FL, sb.toString() );
+ this.set(CommonParams.FL, sb.toString());
return this;
}
-
+
public SolrQuery addField(String field) {
return addValueToParam(CommonParams.FL, field);
}
public String getFields() {
String fields = this.get(CommonParams.FL);
- if (fields!=null && fields.equals("score")) {
+ if (fields != null && fields.equals("score")) {
fields = "*, score";
}
return fields;
@@ -1078,10 +1071,10 @@ public class SolrQuery extends ModifiableSolrParams
private static Pattern scorePattern = Pattern.compile("(^|[, ])score");
public SolrQuery setIncludeScore(boolean includeScore) {
- String fields = get(CommonParams.FL,"*");
+ String fields = get(CommonParams.FL, "*");
if (includeScore) {
- if (!scorePattern.matcher(fields).find()) {
- this.set(CommonParams.FL, fields+",score");
+ if (!scorePattern.matcher(fields).find()) {
+ this.set(CommonParams.FL, fields + ",score");
}
} else {
this.set(CommonParams.FL, scorePattern.matcher(fields).replaceAll(""));
@@ -1099,17 +1092,15 @@ public class SolrQuery extends ModifiableSolrParams
}
public SolrQuery setRows(Integer rows) {
- if( rows == null ) {
- this.remove( CommonParams.ROWS );
- }
- else {
+ if (rows == null) {
+ this.remove(CommonParams.ROWS);
+ } else {
this.set(CommonParams.ROWS, rows);
}
return this;
}
- public Integer getRows()
- {
+ public Integer getRows() {
return this.getInt(CommonParams.ROWS);
}
@@ -1122,27 +1113,24 @@ public class SolrQuery extends ModifiableSolrParams
this.set(CommonParams.DISTRIB, String.valueOf(val));
}
-
public SolrQuery setStart(Integer start) {
- if( start == null ) {
- this.remove( CommonParams.START );
- }
- else {
+ if (start == null) {
+ this.remove(CommonParams.START);
+ } else {
this.set(CommonParams.START, start);
}
return this;
}
-
- public Integer getStart()
- {
+
+ public Integer getStart() {
return this.getInt(CommonParams.START);
}
/**
* The Request Handler to use (see the solrconfig.xml), which is stored in the "qt" parameter.
- * Normally it starts with a '/' and if so it will be used by
- * {@link org.apache.solr.client.solrj.request.QueryRequest#getPath()} in the URL instead of the "qt" parameter.
- * If this is left blank, then the default of "/select" is assumed.
+ * Normally it starts with a '/' and if so it will be used by {@link
+ * org.apache.solr.client.solrj.request.QueryRequest#getPath()} in the URL instead of the "qt"
+ * parameter. If this is left blank, then the default of "/select" is assumed.
*
* @param qt The Request Handler name corresponding to one in solrconfig.xml on the server.
* @return this
@@ -1160,7 +1148,7 @@ public class SolrQuery extends ModifiableSolrParams
* @return this
* @see ModifiableSolrParams#set(String,String[])
*/
- public SolrQuery setParam(String name, String ... values) {
+ public SolrQuery setParam(String name, String... values) {
this.set(name, values);
return this;
}
@@ -1174,7 +1162,7 @@ public class SolrQuery extends ModifiableSolrParams
return this;
}
- /** get a deep copy of this object **/
+ /** get a deep copy of this object * */
public SolrQuery getCopy() {
SolrQuery q = new SolrQuery();
for (String name : this.getParameterNames()) {
@@ -1182,16 +1170,15 @@ public class SolrQuery extends ModifiableSolrParams
}
return q;
}
-
+
/**
- * Set the maximum time allowed for this query. If the query takes more time
- * than the specified milliseconds, a timeout occurs and partial (or no)
- * results may be returned.
- *
- * If given Integer is null, then this parameter is removed from the request
- *
- *@param milliseconds the time in milliseconds allowed for this query
- */
+ * Set the maximum time allowed for this query. If the query takes more time than the specified
+ * milliseconds, a timeout occurs and partial (or no) results may be returned.
+ *
+ * <p>If given Integer is null, then this parameter is removed from the request
+ *
+ * @param milliseconds the time in milliseconds allowed for this query
+ */
public SolrQuery setTimeAllowed(Integer milliseconds) {
if (milliseconds == null) {
this.remove(CommonParams.TIME_ALLOWED);
@@ -1200,10 +1187,8 @@ public class SolrQuery extends ModifiableSolrParams
}
return this;
}
-
- /**
- * Get the maximum time allowed for this query.
- */
+
+ /** Get the maximum time allowed for this query. */
public Integer getTimeAllowed() {
return this.getInt(CommonParams.TIME_ALLOWED);
}
@@ -1211,33 +1196,33 @@ public class SolrQuery extends ModifiableSolrParams
///////////////////////
// Utility functions
///////////////////////
-
+
private String toSortString(String field, ORDER order) {
return field.trim() + ' ' + String.valueOf(order).trim();
}
-
+
private String join(String a, String b, String sep) {
StringBuilder sb = new StringBuilder();
- if (a!=null && a.length()>0) {
+ if (a != null && a.length() > 0) {
sb.append(a);
sb.append(sep);
- }
- if (b!=null && b.length()>0) {
+ }
+ if (b != null && b.length() > 0) {
sb.append(b);
}
return sb.toString().trim();
}
-
+
private SolrQuery addValueToParam(String name, String value) {
String tmp = this.get(name);
tmp = join(tmp, value, ",");
this.set(name, tmp);
return this;
}
-
+
private String join(String[] vals, String sep, String removeVal) {
StringBuilder sb = new StringBuilder();
- for (int i=0; i<vals.length; i++) {
+ for (int i = 0; i < vals.length; i++) {
if (!vals[i].equals(removeVal)) {
if (sb.length() > 0) {
sb.append(sep);
@@ -1250,12 +1235,12 @@ public class SolrQuery extends ModifiableSolrParams
/**
* A single sort clause, encapsulating what to sort and the sort order.
- * <p>
- * The item specified can be "anything sortable" by solr; some examples
- * include a simple field name, the constant string {@code score}, and functions
- * such as {@code sum(x_f, y_f)}.
- * <p>
- * A SortClause can be created through different mechanisms:
+ *
+ * <p>The item specified can be "anything sortable" by solr; some examples include a simple field
+ * name, the constant string {@code score}, and functions such as {@code sum(x_f, y_f)}.
+ *
+ * <p>A SortClause can be created through different mechanisms:
+ *
* <PRE><code>
* new SortClause("product", SolrQuery.ORDER.asc);
* new SortClause("product", "asc");
@@ -1272,6 +1257,7 @@ public class SolrQuery extends ModifiableSolrParams
/**
* Creates a SortClause based on item and order
+ *
* @param item item to sort on
* @param order direction to sort
*/
@@ -1282,6 +1268,7 @@ public class SolrQuery extends ModifiableSolrParams
/**
* Creates a SortClause based on item and order
+ *
* @param item item to sort on
* @param order string value for direction to sort
*/
@@ -1291,14 +1278,16 @@ public class SolrQuery extends ModifiableSolrParams
/**
* Creates an ascending SortClause for an item
+ *
* @param item item to sort on
*/
- public static SortClause create (String item, ORDER order) {
+ public static SortClause create(String item, ORDER order) {
return new SortClause(item, order);
}
/**
* Creates a SortClause based on item and order
+ *
* @param item item to sort on
* @param order string value for direction to sort
*/
@@ -1308,22 +1297,25 @@ public class SolrQuery extends ModifiableSolrParams
/**
* Creates an ascending SortClause for an item
+ *
* @param item item to sort on
*/
- public static SortClause asc (String item) {
+ public static SortClause asc(String item) {
return new SortClause(item, ORDER.asc);
}
/**
* Creates a decending SortClause for an item
+ *
* @param item item to sort on
*/
- public static SortClause desc (String item) {
+ public static SortClause desc(String item) {
return new SortClause(item, ORDER.desc);
}
/**
* Gets the item to sort, typically a function or a fieldname
+ *
* @return item to sort
*/
public String getItem() {
@@ -1332,32 +1324,40 @@ public class SolrQuery extends ModifiableSolrParams
/**
* Gets the order to sort
+ *
* @return order to sort
*/
public ORDER getOrder() {
return order;
}
- public boolean equals(Object other){
+ public boolean equals(Object other) {
if (this == other) return true;
if (!(other instanceof SortClause)) return false;
final SortClause that = (SortClause) other;
return this.getItem().equals(that.getItem()) && this.getOrder().equals(that.getOrder());
}
- public int hashCode(){
+ public int hashCode() {
return this.getItem().hashCode();
}
/**
* Gets a human readable description of the sort clause.
- * <p>
- * The returned string is not suitable for passing to Solr,
- * but may be useful in debug output and the like.
+ *
+ * <p>The returned string is not suitable for passing to Solr, but may be useful in debug output
+ * and the like.
+ *
* @return a description of the current sort clause
*/
public String toString() {
- return "[" + getClass().getSimpleName() + ": item=" + getItem() + "; order=" + getOrder() + "]";
+ return "["
+ + getClass().getSimpleName()
+ + ": item="
+ + getItem()
+ + "; order="
+ + getOrder()
+ + "]";
}
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
index f0ff3bf..643c47c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java
@@ -25,16 +25,11 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-
import org.apache.solr.client.solrj.request.RequestWriter;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
-/**
- *
- *
- * @since solr 1.3
- */
+/** @since solr 1.3 */
public abstract class SolrRequest<T extends SolrResponse> implements Serializable {
// This user principal is typically used by Auth plugins during distributed/sharded search
private Principal userPrincipal;
@@ -68,15 +63,16 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
SERVER
};
- public static final Set<String> SUPPORTED_METHODS = Set.of(
- METHOD.GET.toString(),
- METHOD.POST.toString(),
- METHOD.PUT.toString(),
- METHOD.DELETE.toString());
+ public static final Set<String> SUPPORTED_METHODS =
+ Set.of(
+ METHOD.GET.toString(),
+ METHOD.POST.toString(),
+ METHOD.PUT.toString(),
+ METHOD.DELETE.toString());
private METHOD method = METHOD.GET;
private String path = null;
- private Map<String,String> headers;
+ private Map<String, String> headers;
private ResponseParser responseParser;
private StreamingResponseCallback callback;
@@ -85,17 +81,17 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
protected boolean usev2;
protected boolean useBinaryV2;
- /**If set to true, every request that implements {@link V2RequestSupport} will be converted
- * to a V2 API call
+ /**
+ * If set to true, every request that implements {@link V2RequestSupport} will be converted to a
+ * V2 API call
*/
- public SolrRequest<T> setUseV2(boolean flag){
+ public SolrRequest<T> setUseV2(boolean flag) {
this.usev2 = flag;
return this;
}
- /**If set to true use javabin instead of json (default)
- */
- public SolrRequest<T> setUseBinaryV2(boolean flag){
+ /** If set to true use javabin instead of json (default) */
+ public SolrRequest<T> setUseBinaryV2(boolean flag) {
this.useBinaryV2 = flag;
return this;
}
@@ -110,28 +106,29 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
return this;
}
- public String getBasicAuthUser(){
+ public String getBasicAuthUser() {
return basicAuthUser;
}
- public String getBasicAuthPassword(){
+
+ public String getBasicAuthPassword() {
return basicAuthPwd;
}
-
- //---------------------------------------------------------
- //---------------------------------------------------------
- public SolrRequest( METHOD m, String path )
- {
+ // ---------------------------------------------------------
+ // ---------------------------------------------------------
+
+ public SolrRequest(METHOD m, String path) {
this.method = m;
this.path = path;
}
- //---------------------------------------------------------
- //---------------------------------------------------------
+ // ---------------------------------------------------------
+ // ---------------------------------------------------------
public METHOD getMethod() {
return method;
}
+
public void setMethod(METHOD method) {
this.method = method;
}
@@ -139,21 +136,20 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
public String getPath() {
return path;
}
+
public void setPath(String path) {
this.path = path;
}
- /**
- *
- * @return The {@link org.apache.solr.client.solrj.ResponseParser}
- */
+ /** @return The {@link org.apache.solr.client.solrj.ResponseParser} */
public ResponseParser getResponseParser() {
return responseParser;
}
/**
- * Optionally specify how the Response should be parsed. Not all server implementations require a ResponseParser
- * to be specified.
+ * Optionally specify how the Response should be parsed. Not all server implementations require a
+ * ResponseParser to be specified.
+ *
* @param responseParser The {@link org.apache.solr.client.solrj.ResponseParser}
*/
public void setResponseParser(ResponseParser responseParser) {
@@ -168,9 +164,7 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
this.callback = callback;
}
- /**
- * Parameter keys that are sent via the query string
- */
+ /** Parameter keys that are sent via the query string */
public Set<String> getQueryParams() {
return this.queryParams;
}
@@ -179,16 +173,12 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
this.queryParams = queryParams;
}
- /**
- * This method defines the type of this Solr request.
- */
+ /** This method defines the type of this Solr request. */
public abstract String getRequestType();
public abstract SolrParams getParams();
- /**
- * @deprecated Please use {@link SolrRequest#getContentWriter(String)} instead.
- */
+ /** @deprecated Please use {@link SolrRequest#getContentWriter(String)} instead. */
@Deprecated
public Collection<ContentStream> getContentStreams() throws IOException {
return null;
@@ -197,7 +187,8 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
/**
* If a request object wants to do a push write, implement this method.
*
- * @param expectedType This is the type that the RequestWriter would like to get. But, it is OK to send any format
+ * @param expectedType This is the type that the RequestWriter would like to get. But, it is OK to
+ * send any format
*/
public RequestWriter.ContentWriter getContentWriter(String expectedType) {
return null;
@@ -205,6 +196,7 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
/**
* Create a new SolrResponse to hold the response from the server
+ *
* @param client the {@link SolrClient} the request will be sent to
*/
protected abstract T createResponse(SolrClient client);
@@ -214,13 +206,12 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
*
* @param client the SolrClient to communicate with
* @param collection the collection to execute the request against
- *
* @return the response
- *
* @throws SolrServerException if there is an error on the Solr server
* @throws IOException if there is a communication error
*/
- public final T process(SolrClient client, String collection) throws SolrServerException, IOException {
+ public final T process(SolrClient client, String collection)
+ throws SolrServerException, IOException {
long startNanos = System.nanoTime();
T res = createResponse(client);
res.setResponse(client.request(this, collection));
@@ -233,9 +224,7 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
* Send this request to a {@link SolrClient} and return the response
*
* @param client the SolrClient to communicate with
- *
* @return the response
- *
* @throws SolrServerException if there is an error on the Solr server
* @throws IOException if there is a communication error
*/
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java
index 620b1a4..f6e88e0 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrResponse.java
@@ -16,25 +16,19 @@
*/
package org.apache.solr.client.solrj;
-import org.apache.solr.common.MapWriter;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.SuppressForbidden;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import org.apache.solr.common.MapWriter;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SuppressForbidden;
-
-/**
- *
- *
- * @since solr 1.3
- */
+/** @since solr 1.3 */
public abstract class SolrResponse implements Serializable, MapWriter {
/** make this compatible with earlier versions */
@@ -42,11 +36,11 @@ public abstract class SolrResponse implements Serializable, MapWriter {
/** Elapsed time in milliseconds for the request as seen from the client. */
public abstract long getElapsedTime();
-
+
public abstract void setResponse(NamedList<Object> rsp);
public abstract void setElapsedTime(long elapsedTime);
-
+
public abstract NamedList<Object> getResponse();
@Override
@@ -60,10 +54,11 @@ public abstract class SolrResponse implements Serializable, MapWriter {
return null;
}
Integer rspCode = (Integer) exp.get("rspCode");
- ErrorCode errorCode = rspCode != null && rspCode != -1 ? ErrorCode.getErrorCode(rspCode) : ErrorCode.SERVER_ERROR;
- return new SolrException(errorCode, (String)exp.get("msg"));
+ ErrorCode errorCode =
+ rspCode != null && rspCode != -1 ? ErrorCode.getErrorCode(rspCode) : ErrorCode.SERVER_ERROR;
+ return new SolrException(errorCode, (String) exp.get("msg"));
}
-
+
@SuppressForbidden(reason = "XXX: security hole")
@Deprecated
public static byte[] serializable(SolrResponse response) {
@@ -76,7 +71,7 @@ public abstract class SolrResponse implements Serializable, MapWriter {
throw new SolrException(ErrorCode.SERVER_ERROR, e);
}
}
-
+
@SuppressForbidden(reason = "XXX: security hole")
@Deprecated
public static SolrResponse deserialize(byte[] bytes) {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrServerException.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrServerException.java
index 2616a5b..da267a6 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrServerException.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrServerException.java
@@ -16,15 +16,15 @@
*/
package org.apache.solr.client.solrj;
-/** Exception to catch all types of communication / parsing issues associated with talking to SOLR
- *
+/**
+ * Exception to catch all types of communication / parsing issues associated with talking to SOLR
*
* @since solr 1.3
*/
public class SolrServerException extends Exception {
private static final long serialVersionUID = -3371703521752000294L;
-
+
public SolrServerException(String message, Throwable cause) {
super(message, cause);
}
@@ -36,12 +36,12 @@ public class SolrServerException extends Exception {
public SolrServerException(Throwable cause) {
super(cause);
}
-
+
public Throwable getRootCause() {
Throwable t = this;
while (true) {
Throwable cause = t.getCause();
- if (cause!=null) {
+ if (cause != null) {
t = cause;
} else {
break;
@@ -49,5 +49,4 @@ public class SolrServerException extends Exception {
}
return t;
}
-
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/StreamingResponseCallback.java b/solr/solrj/src/java/org/apache/solr/client/solrj/StreamingResponseCallback.java
index 1137709..3853e9c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/StreamingResponseCallback.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/StreamingResponseCallback.java
@@ -20,17 +20,17 @@ import org.apache.solr.common.SolrDocument;
/**
* A callback interface for streaming response
- *
+ *
* @since solr 4.0
*/
public abstract class StreamingResponseCallback {
/*
* Called for each SolrDocument in the response
*/
- public abstract void streamSolrDocument( SolrDocument doc );
+ public abstract void streamSolrDocument(SolrDocument doc);
/*
* Called at the beginning of each DocList (and SolrDocumentList)
*/
- public abstract void streamDocListInfo( long numFound, long start, Float maxScore );
+ public abstract void streamDocListInfo(long numFound, long start, Float maxScore);
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/V2RequestSupport.java b/solr/solrj/src/java/org/apache/solr/client/solrj/V2RequestSupport.java
index 6e75749..d65edd1 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/V2RequestSupport.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/V2RequestSupport.java
@@ -17,15 +17,9 @@
package org.apache.solr.client.solrj;
-/**A a request object is able to convert itself to V2 Request
- * it should implement this interface
- *
- */
+/** A a request object is able to convert itself to V2 Request it should implement this interface */
public interface V2RequestSupport {
- /**If usev2 flag is set to true, return V2Request, if not,
- * return V1 request object
- *
- */
+ /** If usev2 flag is set to true, return V2Request, if not, return V1 request object */
@SuppressWarnings({"rawtypes"})
SolrRequest getV2Request();
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
index dc84b05..beff185 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/DocumentObjectBinder.java
@@ -16,31 +16,28 @@
*/
package org.apache.solr.client.solrj.beans;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.common.util.SuppressForbidden;
-
import java.lang.reflect.*;
+import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
-import java.util.regex.Pattern;
import java.util.concurrent.ConcurrentHashMap;
-import java.nio.ByteBuffer;
+import java.util.regex.Pattern;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.util.SuppressForbidden;
/**
* A class to map objects to and from solr documents.
*
- *
* @since solr 1.3
*/
public class DocumentObjectBinder {
private final Map<Class<?>, List<DocField>> infocache = new ConcurrentHashMap<>();
- public DocumentObjectBinder() {
- }
+ public DocumentObjectBinder() {}
public <T> List<T> getBeans(Class<T> clazz, SolrDocumentList solrDocList) {
List<DocField> fields = getDocFields(clazz);
@@ -80,9 +77,9 @@ public class DocumentObjectBinder {
SolrInputDocument doc = new SolrInputDocument();
for (DocField field : fields) {
- if (field.dynamicFieldNamePatternMatcher != null &&
- field.get(obj) != null &&
- field.isContainedInMap) {
+ if (field.dynamicFieldNamePatternMatcher != null
+ && field.get(obj) != null
+ && field.isContainedInMap) {
@SuppressWarnings({"unchecked"})
Map<String, Object> mapValue = (Map<String, Object>) field.get(obj);
@@ -120,7 +117,7 @@ public class DocumentObjectBinder {
private List<DocField> getDocFields(Class<?> clazz) {
List<DocField> fields = infocache.get(clazz);
if (fields == null) {
- synchronized(infocache) {
+ synchronized (infocache) {
infocache.put(clazz, fields = collectInfo(clazz));
}
}
@@ -141,11 +138,17 @@ public class DocumentObjectBinder {
boolean childFieldFound = false;
for (AccessibleObject member : members) {
if (member.isAnnotationPresent(Field.class)) {
- AccessController.doPrivileged((PrivilegedAction<Void>) () -> { member.setAccessible(true); return null; });
+ AccessController.doPrivileged(
+ (PrivilegedAction<Void>)
+ () -> {
+ member.setAccessible(true);
+ return null;
+ });
DocField df = new DocField(member);
if (df.child != null) {
if (childFieldFound)
- throw new BindingException(clazz.getName() + " cannot have more than one Field with child=true");
+ throw new BindingException(
+ clazz.getName() + " cannot have more than one Field with child=true");
childFieldFound = true;
}
fields.add(df);
@@ -196,7 +199,7 @@ public class DocumentObjectBinder {
gname = "is" + setter.getName().substring(3);
try {
getter = setter.getDeclaringClass().getMethod(gname, (Class[]) null);
- } catch(Exception ex2) {
+ } catch (Exception ex2) {
// no getter -- don't worry about it...
}
}
@@ -217,11 +220,13 @@ public class DocumentObjectBinder {
name = setter.getName();
}
}
- } else if (annotation.value().indexOf('*') >= 0) { //dynamic fields are annotated as @Field("categories_*")
- //if the field was annotated as a dynamic field, convert the name into a pattern
- //the wildcard (*) is supposed to be either a prefix or a suffix, hence the use of replaceFirst
+ } else if (annotation.value().indexOf('*') >= 0) {
+ // dynamic fields are annotated as @Field("categories_*")
+ // if the field was annotated as a dynamic field, convert the name into a pattern
+ // the wildcard (*) is supposed to be either a prefix or a suffix, hence the use of
+ // replaceFirst
name = annotation.value().replaceFirst("\\*", "\\.*");
- dynamicFieldNamePatternMatcher = Pattern.compile("^"+name+"$");
+ dynamicFieldNamePatternMatcher = Pattern.compile("^" + name + "$");
} else {
name = annotation.value();
}
@@ -233,8 +238,12 @@ public class DocumentObjectBinder {
} else {
Class<?>[] params = setter.getParameterTypes();
if (params.length != 1) {
- throw new BindingException("Invalid setter method (" + setter +
- "). A setter must have one and only one parameter but we found " + params.length + " parameters.");
+ throw new BindingException(
+ "Invalid setter method ("
+ + setter
+ + "). A setter must have one and only one parameter but we found "
+ + params.length
+ + " parameters.");
}
type = params[0];
}
@@ -247,7 +256,7 @@ public class DocumentObjectBinder {
type = Object.class;
}
} else if (type == byte[].class) {
- //no op
+ // no op
} else if (type.isArray()) {
isArray = true;
if (annotation.child()) {
@@ -255,40 +264,49 @@ public class DocumentObjectBinder {
} else {
type = type.getComponentType();
}
- } else if (type == Map.class || type == HashMap.class) { //corresponding to the support for dynamicFields
- if (annotation.child()) throw new BindingException("Map should is not a valid type for a child document");
+ } else if (type == Map.class
+ || type == HashMap.class) { // corresponding to the support for dynamicFields
+ if (annotation.child())
+ throw new BindingException("Map should is not a valid type for a child document");
isContainedInMap = true;
- //assigned a default type
+ // assigned a default type
type = Object.class;
if (field != null) {
if (field.getGenericType() instanceof ParameterizedType) {
- //check what are the generic values
+ // check what are the generic values
ParameterizedType parameterizedType = (ParameterizedType) field.getGenericType();
Type[] types = parameterizedType.getActualTypeArguments();
if (types != null && types.length == 2 && types[0] == String.class) {
- //the key should always be String
- //Raw and primitive types
+ // the key should always be String
+ // Raw and primitive types
if (types[1] instanceof Class) {
- //the value could be multivalued then it is a List, Collection, ArrayList
- if (types[1] == Collection.class || types[1] == List.class || types[1] == ArrayList.class) {
+ // the value could be multivalued then it is a List, Collection, ArrayList
+ if (types[1] == Collection.class
+ || types[1] == List.class
+ || types[1] == ArrayList.class) {
type = Object.class;
isList = true;
} else {
- //else assume it is a primitive and put in the source type itself
+ // else assume it is a primitive and put in the source type itself
type = (Class) types[1];
}
- } else if (types[1] instanceof ParameterizedType) { //Of all the Parameterized types, only List is supported
+ } else if (types[1]
+ instanceof
+ ParameterizedType) { // Of all the Parameterized types, only List is supported
Type rawType = ((ParameterizedType) types[1]).getRawType();
- if (rawType == Collection.class || rawType == List.class || rawType == ArrayList.class) {
+ if (rawType == Collection.class
+ || rawType == List.class
+ || rawType == ArrayList.class) {
type = Object.class;
isList = true;
}
- } else if (types[1] instanceof GenericArrayType) { //Array types
+ } else if (types[1] instanceof GenericArrayType) { // Array types
type = (Class) ((GenericArrayType) types[1]).getGenericComponentType();
isArray = true;
- } else { //Throw an Exception if types are not known
- throw new BindingException("Allowed type for values of mapping a dynamicField are : " +
- "Object, Object[] and List");
+ } else { // Throw an Exception if types are not known
+ throw new BindingException(
+ "Allowed type for values of mapping a dynamicField are : "
+ + "Object, Object[] and List");
}
}
}
@@ -302,29 +320,30 @@ public class DocumentObjectBinder {
private void populateChild(Type typ) {
if (typ == null) {
- throw new RuntimeException("no type information available for" + (field == null ? setter : field));
+ throw new RuntimeException(
+ "no type information available for" + (field == null ? setter : field));
}
- if (typ.getClass() == Class.class) {//of type class
+ if (typ.getClass() == Class.class) { // of type class
type = (Class) typ;
} else if (typ instanceof ParameterizedType) {
try {
type = Class.forName(((ParameterizedType) typ).getActualTypeArguments()[0].getTypeName());
} catch (ClassNotFoundException e) {
- throw new BindingException("Invalid type information available for" + (field == null ? setter : field));
+ throw new BindingException(
+ "Invalid type information available for" + (field == null ? setter : field));
}
} else {
- throw new BindingException("Invalid type information available for" + (field == null ? setter : field));
-
+ throw new BindingException(
+ "Invalid type information available for" + (field == null ? setter : field));
}
child = getDocFields(type);
}
/**
- * Called by the {@link #inject} method to read the value(s) for a field
- * This method supports reading of all "matching" fieldName's in the <code>SolrDocument</code>
- *
- * Returns <code>SolrDocument.getFieldValue</code> for regular fields,
- * and <code>Map<String, List<Object>></code> for a dynamic field. The key is all matching fieldName's.
+ * Called by the {@link #inject} method to read the value(s) for a field This method supports
+ * reading of all "matching" fieldName's in the <code>SolrDocument</code> Returns <code>
+ * SolrDocument.getFieldValue</code> for regular fields, and <code>Map<String, List<Object>>
+ * </code> for a dynamic field. The key is all matching fieldName's.
*/
private Object getFieldValue(SolrDocument solrDocument) {
if (child != null) {
@@ -349,7 +368,7 @@ public class DocumentObjectBinder {
}
Object fieldValue = solrDocument.getFieldValue(name);
if (fieldValue != null) {
- //this is not a dynamic field. so return the value
+ // this is not a dynamic field. so return the value
return fieldValue;
}
@@ -357,7 +376,7 @@ public class DocumentObjectBinder {
return null;
}
- //reading dynamic field values
+ // reading dynamic field values
Map<String, Object> allValuesMap = null;
List<Object> allValuesList = null;
if (isContainedInMap) {
@@ -408,7 +427,7 @@ public class DocumentObjectBinder {
<T> void inject(T obj, SolrDocument sdoc) {
Object val = getFieldValue(sdoc);
- if(val == null) {
+ if (val == null) {
return;
}
@@ -427,17 +446,16 @@ public class DocumentObjectBinder {
if (!(val instanceof List)) {
List<Object> list = new ArrayList<>();
list.add(val);
- val = list;
+ val = list;
}
set(obj, val);
} else if (isContainedInMap) {
if (val instanceof Map) {
- set(obj, val);
+ set(obj, val);
}
} else {
set(obj, val);
}
-
}
private void set(Object obj, Object v) {
@@ -450,9 +468,9 @@ public class DocumentObjectBinder {
} else if (setter != null) {
setter.invoke(obj, v);
}
- }
- catch (Exception e) {
- throw new BindingException("Exception while setting value : " + v + " on " + (field != null ? field : setter), e);
+ } catch (Exception e) {
+ throw new BindingException(
+ "Exception while setting value : " + v + " on " + (field != null ? field : setter), e);
}
}
@@ -464,7 +482,10 @@ public class DocumentObjectBinder {
throw new BindingException("Exception while getting value: " + field, e);
}
} else if (getter == null) {
- throw new BindingException("Missing getter for field: " + name + " -- You can only call the 'get' for fields that have a field of 'get' method");
+ throw new BindingException(
+ "Missing getter for field: "
+ + name
+ + " -- You can only call the 'get' for fields that have a field of 'get' method");
}
try {
@@ -474,5 +495,6 @@ public class DocumentObjectBinder {
}
}
}
+
public static final String DEFAULT = "#default";
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/Field.java b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/Field.java
index 9bfa80a..cf7f782 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/Field.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/Field.java
@@ -20,13 +20,12 @@ import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import static org.apache.solr.client.solrj.beans.DocumentObjectBinder.DEFAULT;
-import java.lang.annotation.Target;
import java.lang.annotation.Retention;
-
+import java.lang.annotation.Target;
/**
- * This class can be used to annotate a field or a setter an any class
- * and SolrJ would help you convert to SolrInputDocument and from SolrDocument
+ * This class can be used to annotate a field or a setter an any class and SolrJ would help you
+ * convert to SolrInputDocument and from SolrDocument
*
* @since solr 1.3
*/
@@ -34,5 +33,6 @@ import java.lang.annotation.Retention;
@Retention(RUNTIME)
public @interface Field {
boolean child() default false;
+
String value() default DEFAULT;
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/package-info.java b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/package-info.java
index 890005f..a8f7d11 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/beans/package-info.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/beans/package-info.java
@@ -14,10 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Annotation based mapping of client objects to Solr documents.
- */
-package org.apache.solr.client.solrj.beans;
-
+/** Annotation based mapping of client objects to Solr documents. */
+package org.apache.solr.client.solrj.beans;
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/AlreadyExistsException.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/AlreadyExistsException.java
index ef9ee0c..9dbe29d 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/AlreadyExistsException.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/AlreadyExistsException.java
@@ -16,9 +16,7 @@
*/
package org.apache.solr.client.solrj.cloud;
-/**
- *
- */
+/** */
public class AlreadyExistsException extends Exception {
private final String id;
@@ -31,5 +29,4 @@ public class AlreadyExistsException extends Exception {
public String getId() {
return id;
}
-
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/BadVersionException.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/BadVersionException.java
index 742f771..700b1c4 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/BadVersionException.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/BadVersionException.java
@@ -16,9 +16,7 @@
*/
package org.apache.solr.client.solrj.cloud;
-/**
- *
- */
+/** */
public class BadVersionException extends Exception {
private final String path;
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DelegatingCloudManager.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DelegatingCloudManager.java
index dde4093..a8039fd 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DelegatingCloudManager.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DelegatingCloudManager.java
@@ -18,72 +18,76 @@ package org.apache.solr.client.solrj.cloud;
import java.io.IOException;
import java.util.Map;
-
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.impl.ClusterStateProvider;
import org.apache.solr.common.util.ObjectCache;
import org.apache.solr.common.util.TimeSource;
-/**
- * Base class for overriding some behavior of {@link SolrCloudManager}.
- */
+/** Base class for overriding some behavior of {@link SolrCloudManager}. */
public class DelegatingCloudManager implements SolrCloudManager {
- protected final SolrCloudManager delegate;
- private ObjectCache objectCache = new ObjectCache();
- private TimeSource timeSource = TimeSource.NANO_TIME;
+ protected final SolrCloudManager delegate;
+ private ObjectCache objectCache = new ObjectCache();
+ private TimeSource timeSource = TimeSource.NANO_TIME;
- public DelegatingCloudManager(SolrCloudManager delegate) {
- this.delegate = delegate;
- }
+ public DelegatingCloudManager(SolrCloudManager delegate) {
+ this.delegate = delegate;
+ }
- @Override
- public ClusterStateProvider getClusterStateProvider() {
- return delegate.getClusterStateProvider();
- }
+ @Override
+ public ClusterStateProvider getClusterStateProvider() {
+ return delegate.getClusterStateProvider();
+ }
- @Override
- public NodeStateProvider getNodeStateProvider() {
- return delegate.getNodeStateProvider();
- }
+ @Override
+ public NodeStateProvider getNodeStateProvider() {
+ return delegate.getNodeStateProvider();
+ }
- @Override
- public DistribStateManager getDistribStateManager() {
- return delegate.getDistribStateManager();
- }
+ @Override
+ public DistribStateManager getDistribStateManager() {
+ return delegate.getDistribStateManager();
+ }
- @Override
- public DistributedQueueFactory getDistributedQueueFactory() {
- return delegate.getDistributedQueueFactory();
- }
+ @Override
+ public DistributedQueueFactory getDistributedQueueFactory() {
+ return delegate.getDistributedQueueFactory();
+ }
- @Override
- public ObjectCache getObjectCache() {
- return delegate == null ? objectCache : delegate.getObjectCache();
- }
+ @Override
+ public ObjectCache getObjectCache() {
+ return delegate == null ? objectCache : delegate.getObjectCache();
+ }
- @Override
- public boolean isClosed() {
- return delegate.isClosed();
- }
+ @Override
+ public boolean isClosed() {
+ return delegate.isClosed();
+ }
- @Override
- public TimeSource getTimeSource() {
- return delegate == null ? timeSource : delegate.getTimeSource();
- }
+ @Override
+ public TimeSource getTimeSource() {
+ return delegate == null ? timeSource : delegate.getTimeSource();
+ }
- @Override
- public <T extends SolrResponse> T request(SolrRequest<T> req) throws IOException {
- return delegate.request(req);
- }
+ @Override
+ public <T extends SolrResponse> T request(SolrRequest<T> req) throws IOException {
+ return delegate.request(req);
+ }
- @Override
- public byte[] httpRequest(String url, SolrRequest.METHOD method, Map<String, String> headers, String payload, int timeout, boolean followRedirects) throws IOException {
- return delegate.httpRequest(url, method, headers, payload, timeout, followRedirects);
- }
+ @Override
+ public byte[] httpRequest(
+ String url,
+ SolrRequest.METHOD method,
+ Map<String, String> headers,
+ String payload,
+ int timeout,
+ boolean followRedirects)
+ throws IOException {
+ return delegate.httpRequest(url, method, headers, payload, timeout, followRedirects);
+ }
- @Override
- public void close() throws IOException {
- delegate.close();
- }
+ @Override
+ public void close() throws IOException {
+ delegate.close();
+ }
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DelegatingClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DelegatingClusterStateProvider.java
index 656c068..35ff43d 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DelegatingClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DelegatingClusterStateProvider.java
@@ -21,110 +21,107 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import org.apache.solr.client.solrj.impl.ClusterStateProvider;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.DocCollection;
-/**
- * Base class for overriding some behavior of {@link ClusterStateProvider}
- */
+/** Base class for overriding some behavior of {@link ClusterStateProvider} */
public class DelegatingClusterStateProvider implements ClusterStateProvider {
- protected ClusterStateProvider delegate;
+ protected ClusterStateProvider delegate;
- public DelegatingClusterStateProvider(ClusterStateProvider delegate) {
- this.delegate = delegate;
- }
+ public DelegatingClusterStateProvider(ClusterStateProvider delegate) {
+ this.delegate = delegate;
+ }
- @Override
- public ClusterState.CollectionRef getState(String collection) {
- if (delegate != null) {
- return delegate.getState(collection);
- } else {
- return null;
- }
+ @Override
+ public ClusterState.CollectionRef getState(String collection) {
+ if (delegate != null) {
+ return delegate.getState(collection);
+ } else {
+ return null;
}
+ }
- @Override
- public Set<String> getLiveNodes() {
- if (delegate != null) {
- return delegate.getLiveNodes();
- } else {
- return Collections.emptySet();
- }
+ @Override
+ public Set<String> getLiveNodes() {
+ if (delegate != null) {
+ return delegate.getLiveNodes();
+ } else {
+ return Collections.emptySet();
}
+ }
- @Override
- public List<String> resolveAlias(String alias) {
- if (delegate != null) {
- return delegate.resolveAlias(alias);
- } else {
- return Collections.singletonList(alias);
- }
+ @Override
+ public List<String> resolveAlias(String alias) {
+ if (delegate != null) {
+ return delegate.resolveAlias(alias);
+ } else {
+ return Collections.singletonList(alias);
}
+ }
- @Override
- public Map<String, String> getAliasProperties(String alias) {
- if (delegate != null) {
- return delegate.getAliasProperties(alias);
- } else {
- return Collections.emptyMap();
- }
+ @Override
+ public Map<String, String> getAliasProperties(String alias) {
+ if (delegate != null) {
+ return delegate.getAliasProperties(alias);
+ } else {
+ return Collections.emptyMap();
}
+ }
- @Override
- public String resolveSimpleAlias(String alias) throws IllegalArgumentException {
- if (delegate != null) {
- return delegate.resolveSimpleAlias(alias);
- } else {
- return alias;
- }
+ @Override
+ public String resolveSimpleAlias(String alias) throws IllegalArgumentException {
+ if (delegate != null) {
+ return delegate.resolveSimpleAlias(alias);
+ } else {
+ return alias;
}
+ }
- @Override
- public ClusterState getClusterState() throws IOException {
- if (delegate != null) {
- return delegate.getClusterState();
- } else {
- return null;
- }
+ @Override
+ public ClusterState getClusterState() throws IOException {
+ if (delegate != null) {
+ return delegate.getClusterState();
+ } else {
+ return null;
}
+ }
- @Override
- public Map<String, Object> getClusterProperties() {
- if (delegate != null) {
- return delegate.getClusterProperties();
- } else {
- return Collections.emptyMap();
- }
+ @Override
+ public Map<String, Object> getClusterProperties() {
+ if (delegate != null) {
+ return delegate.getClusterProperties();
+ } else {
+ return Collections.emptyMap();
}
+ }
- @Override
- public String getPolicyNameByCollection(String coll) {
- if (delegate != null) {
- return delegate.getPolicyNameByCollection(coll);
- } else {
- return null;
- }
+ @Override
+ public String getPolicyNameByCollection(String coll) {
+ if (delegate != null) {
+ return delegate.getPolicyNameByCollection(coll);
+ } else {
+ return null;
}
+ }
- @Override
- public DocCollection getCollection(String name) throws IOException {
- ClusterState cs = getClusterState();
- return cs == null ? null : cs.getCollectionOrNull(name);
- }
+ @Override
+ public DocCollection getCollection(String name) throws IOException {
+ ClusterState cs = getClusterState();
+ return cs == null ? null : cs.getCollectionOrNull(name);
+ }
- @Override
- public void connect() {
- if (delegate != null) {
- delegate.connect();
- }
+ @Override
+ public void connect() {
+ if (delegate != null) {
+ delegate.connect();
}
+ }
- @Override
- public void close() throws IOException {
- if (delegate != null) {
- delegate.close();
- }
+ @Override
+ public void close() throws IOException {
+ if (delegate != null) {
+ delegate.close();
}
+ }
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistribStateManager.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistribStateManager.java
index feae27f..2554389 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistribStateManager.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistribStateManager.java
@@ -23,7 +23,6 @@ import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
-
import org.apache.solr.common.SolrCloseable;
import org.apache.solr.common.cloud.PerReplicaStates;
import org.apache.zookeeper.CreateMode;
@@ -32,53 +31,67 @@ import org.apache.zookeeper.Op;
import org.apache.zookeeper.OpResult;
import org.apache.zookeeper.Watcher;
-/**
- * This interface represents a distributed state repository.
- */
+/** This interface represents a distributed state repository. */
public interface DistribStateManager extends SolrCloseable {
// state accessors
boolean hasData(String path) throws IOException, KeeperException, InterruptedException;
- List<String> listData(String path) throws NoSuchElementException, IOException, KeeperException, InterruptedException;
+ List<String> listData(String path)
+ throws NoSuchElementException, IOException, KeeperException, InterruptedException;
- List<String> listData(String path, Watcher watcher) throws NoSuchElementException, IOException, KeeperException, InterruptedException;
+ List<String> listData(String path, Watcher watcher)
+ throws NoSuchElementException, IOException, KeeperException, InterruptedException;
- VersionedData getData(String path, Watcher watcher) throws NoSuchElementException, IOException, KeeperException, InterruptedException;
+ VersionedData getData(String path, Watcher watcher)
+ throws NoSuchElementException, IOException, KeeperException, InterruptedException;
- default VersionedData getData(String path) throws NoSuchElementException, IOException, KeeperException, InterruptedException {
+ default VersionedData getData(String path)
+ throws NoSuchElementException, IOException, KeeperException, InterruptedException {
return getData(path, null);
}
// state mutators
- void makePath(String path) throws AlreadyExistsException, IOException, KeeperException, InterruptedException;
+ void makePath(String path)
+ throws AlreadyExistsException, IOException, KeeperException, InterruptedException;
- void makePath(String path, byte[] data, CreateMode createMode, boolean failOnExists) throws AlreadyExistsException, IOException, KeeperException, InterruptedException;
+ void makePath(String path, byte[] data, CreateMode createMode, boolean failOnExists)
+ throws AlreadyExistsException, IOException, KeeperException, InterruptedException;
/**
* Create data (leaf) node at specified path.
+ *
* @param path base path name of the node.
* @param data data to be stored.
* @param mode creation mode.
- * @return actual path of the node - in case of sequential nodes this will differ from the base path because
- * of the appended sequence number.
+ * @return actual path of the node - in case of sequential nodes this will differ from the base
+ * path because of the appended sequence number.
*/
- String createData(String path, byte[] data, CreateMode mode) throws AlreadyExistsException, IOException, KeeperException, InterruptedException;
+ String createData(String path, byte[] data, CreateMode mode)
+ throws AlreadyExistsException, IOException, KeeperException, InterruptedException;
- void removeData(String path, int version) throws NoSuchElementException, IOException, NotEmptyException, KeeperException, InterruptedException, BadVersionException;
+ void removeData(String path, int version)
+ throws NoSuchElementException, IOException, NotEmptyException, KeeperException,
+ InterruptedException, BadVersionException;
- void setData(String path, byte[] data, int version) throws BadVersionException, NoSuchElementException, IOException, KeeperException, InterruptedException;
+ void setData(String path, byte[] data, int version)
+ throws BadVersionException, NoSuchElementException, IOException, KeeperException,
+ InterruptedException;
- List<OpResult> multi(final Iterable<Op> ops) throws BadVersionException, NoSuchElementException, AlreadyExistsException, IOException, KeeperException, InterruptedException;
+ List<OpResult> multi(final Iterable<Op> ops)
+ throws BadVersionException, NoSuchElementException, AlreadyExistsException, IOException,
+ KeeperException, InterruptedException;
/**
* List a subtree including the root path, using breadth-first traversal.
+ *
* @param root root path
* @return list of full paths, with the root path being the first element
*/
- default List<String> listTree(String root) throws NoSuchElementException, IOException, KeeperException, InterruptedException {
+ default List<String> listTree(String root)
+ throws NoSuchElementException, IOException, KeeperException, InterruptedException {
Deque<String> queue = new LinkedList<String>();
List<String> tree = new ArrayList<String>();
if (!root.startsWith("/")) {
@@ -101,19 +114,21 @@ public interface DistribStateManager extends SolrCloseable {
return tree;
}
- default PerReplicaStates getReplicaStates(String path) throws KeeperException, InterruptedException {
+ default PerReplicaStates getReplicaStates(String path)
+ throws KeeperException, InterruptedException {
throw new UnsupportedOperationException("Not implemented");
-
-
}
/**
* Remove data recursively.
+ *
* @param root root path
* @param ignoreMissing ignore errors if root or any children path is missing
* @param includeRoot when true delete also the root path
*/
- default void removeRecursively(String root, boolean ignoreMissing, boolean includeRoot) throws NoSuchElementException, IOException, NotEmptyException, KeeperException, InterruptedException, BadVersionException {
+ default void removeRecursively(String root, boolean ignoreMissing, boolean includeRoot)
+ throws NoSuchElementException, IOException, NotEmptyException, KeeperException,
+ InterruptedException, BadVersionException {
List<String> tree;
try {
tree = listTree(root);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistributedQueue.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistributedQueue.java
index 9a31bff..097f013 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistributedQueue.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistributedQueue.java
@@ -19,12 +19,9 @@ package org.apache.solr.client.solrj.cloud;
import java.util.Collection;
import java.util.Map;
import java.util.function.Predicate;
-
import org.apache.solr.common.util.Pair;
-/**
- * Distributed queue component. Methods largely follow those in {@link java.util.Queue}.
- */
+/** Distributed queue component. Methods largely follow those in {@link java.util.Queue}. */
public interface DistributedQueue {
byte[] peek() throws Exception;
@@ -40,19 +37,19 @@ public interface DistributedQueue {
void offer(byte[] data) throws Exception;
- /**
- * Retrieve statistics about the queue size, operations and their timings.
- */
+ /** Retrieve statistics about the queue size, operations and their timings. */
Map<String, Object> getStats();
/**
* Peek multiple elements from the queue in a single call.
+ *
* @param max maximum elements to retrieve
- * @param waitMillis if less than maximum element is in the queue then wait at most this time for at least one new element.
+ * @param waitMillis if less than maximum element is in the queue then wait at most this time for
+ * at least one new element.
* @param acceptFilter peek only elements that pass this filter
* @return peeked elements
* @throws Exception on errors
*/
- Collection<Pair<String, byte[]>> peekElements(int max, long waitMillis, Predicate<String> acceptFilter) throws Exception;
-
+ Collection<Pair<String, byte[]>> peekElements(
+ int max, long waitMillis, Predicate<String> acceptFilter) throws Exception;
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistributedQueueFactory.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistributedQueueFactory.java
index c54ccbd..bd5244a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistributedQueueFactory.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/DistributedQueueFactory.java
@@ -18,9 +18,7 @@ package org.apache.solr.client.solrj.cloud;
import java.io.IOException;
-/**
- *
- */
+/** */
public interface DistributedQueueFactory {
DistributedQueue makeQueue(String path) throws IOException;
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/NodeStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/NodeStateProvider.java
index edf40b7..173c84c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/NodeStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/NodeStateProvider.java
@@ -19,13 +19,10 @@ package org.apache.solr.client.solrj.cloud;
import java.util.Collection;
import java.util.List;
import java.util.Map;
-
import org.apache.solr.common.SolrCloseable;
import org.apache.solr.common.cloud.Replica;
-/**
- * This interface models the access to node and replica information.
- */
+/** This interface models the access to node and replica information. */
public interface NodeStateProvider extends SolrCloseable {
/**
* Get the value of each tag for a given node
@@ -37,9 +34,11 @@ public interface NodeStateProvider extends SolrCloseable {
Map<String, Object> getNodeValues(String node, Collection<String> tags);
/**
- * Get the details of each replica in a node. It attempts to fetch as much details about
- * the replica as mentioned in the keys list. It is not necessary to give all details
- * <p>The format is {collection:shard :[{replicadetails}]}.</p>
+ * Get the details of each replica in a node. It attempts to fetch as much details about the
+ * replica as mentioned in the keys list. It is not necessary to give all details
+ *
+ * <p>The format is {collection:shard :[{replicadetails}]}.
+ *
* @return map of replica infos per collection/shard
*/
Map<String, Map<String, List<Replica>>> getReplicaInfo(String node, Collection<String> keys);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/NotEmptyException.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/NotEmptyException.java
index f75fe02..9fc0ee4 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/NotEmptyException.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/NotEmptyException.java
@@ -16,9 +16,7 @@
*/
package org.apache.solr.client.solrj.cloud;
-/**
- *
- */
+/** */
public class NotEmptyException extends Exception {
private final String path;
@@ -31,5 +29,4 @@ public class NotEmptyException extends Exception {
public String getPath() {
return path;
}
-
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java
index cd6ead0..b693e7d 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/ShardTerms.java
@@ -23,13 +23,10 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
-
import org.apache.solr.common.MapWriter;
import org.apache.solr.common.SolrException;
-/**
- * Hold values of terms, this class is immutable. Create a new instance for every mutation
- */
+/** Hold values of terms, this class is immutable. Create a new instance for every mutation */
public class ShardTerms implements MapWriter {
private static final String RECOVERING_TERM_SUFFIX = "_recovering";
private final Map<String, Long> values;
@@ -37,7 +34,7 @@ public class ShardTerms implements MapWriter {
// ZK node version
private final int version;
- public ShardTerms () {
+ public ShardTerms() {
this(new HashMap<>(), 0);
}
@@ -59,6 +56,7 @@ public class ShardTerms implements MapWriter {
/**
* Can {@code coreNodeName} become leader?
+ *
* @param coreNodeName of the replica
* @return true if {@code coreNodeName} can become leader, false if otherwise
*/
@@ -68,6 +66,7 @@ public class ShardTerms implements MapWriter {
/**
* Is {@code coreNodeName}'s term highest?
+ *
* @param coreNodeName of the replica
* @return true if term of {@code coreNodeName} is highest
*/
@@ -81,14 +80,18 @@ public class ShardTerms implements MapWriter {
}
/**
- * Return a new {@link ShardTerms} in which term of {@code leader} is higher than {@code replicasNeedingRecovery}
+ * Return a new {@link ShardTerms} in which term of {@code leader} is higher than {@code
+ * replicasNeedingRecovery}
+ *
* @param leader coreNodeName of leader
- * @param replicasNeedingRecovery set of replicas in which their terms should be lower than leader's term
+ * @param replicasNeedingRecovery set of replicas in which their terms should be lower than
+ * leader's term
* @return null if term of {@code leader} is already higher than {@code replicasNeedingRecovery}
*/
public ShardTerms increaseTerms(String leader, Set<String> replicasNeedingRecovery) {
if (!values.containsKey(leader)) {
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Can not find leader's term " + leader);
+ throw new SolrException(
+ SolrException.ErrorCode.SERVER_ERROR, "Can not find leader's term " + leader);
}
boolean saveChanges = false;
@@ -100,7 +103,7 @@ public class ShardTerms implements MapWriter {
String key = entry.getKey();
if (replicasNeedingRecovery.contains(key)) foundReplicasInLowerTerms = true;
if (Objects.equals(entry.getValue(), leaderTerm)) {
- if(skipIncreaseTermOf(key, replicasNeedingRecovery)) {
+ if (skipIncreaseTermOf(key, replicasNeedingRecovery)) {
saveChanges = true; // if we don't skip anybody, then there's no reason to increment
} else {
entry.setValue(leaderTerm + 1);
@@ -108,8 +111,8 @@ public class ShardTerms implements MapWriter {
}
}
- // We should skip the optimization if there are no replicasNeedingRecovery present in local terms,
- // this may indicate that the current value is stale
+ // We should skip the optimization if there are no replicasNeedingRecovery present in local
+ // terms, this may indicate that the current value is stale
if (!saveChanges && foundReplicasInLowerTerms) return null;
return new ShardTerms(newValues, version);
}
@@ -123,6 +126,7 @@ public class ShardTerms implements MapWriter {
/**
* Return a new {@link ShardTerms} in which highest terms are not zero
+ *
* @return null if highest terms are already larger than zero
*/
public ShardTerms ensureHighestTermsAreNotZero() {
@@ -138,6 +142,7 @@ public class ShardTerms implements MapWriter {
/**
* Return a new {@link ShardTerms} in which terms for the {@code coreNodeName} are removed
+ *
* @param coreNodeName of the replica
* @return null if term of {@code coreNodeName} is already not exist
*/
@@ -155,6 +160,7 @@ public class ShardTerms implements MapWriter {
/**
* Return a new {@link ShardTerms} in which the associate term of {@code coreNodeName} is not null
+ *
* @param coreNodeName of the replica
* @return null if term of {@code coreNodeName} is already exist
*/
@@ -167,8 +173,9 @@ public class ShardTerms implements MapWriter {
}
/**
- * Return a new {@link ShardTerms} in which the associate term of {@code coreNodeName} is equal to zero,
- * creating it if it does not previously exist.
+ * Return a new {@link ShardTerms} in which the associate term of {@code coreNodeName} is equal to
+ * zero, creating it if it does not previously exist.
+ *
* @param coreNodeName of the replica
* @return null if the term of {@code coreNodeName} already exists and is zero
*/
@@ -183,6 +190,7 @@ public class ShardTerms implements MapWriter {
/**
* Return a new {@link ShardTerms} in which the term of {@code coreNodeName} is max
+ *
* @param coreNodeName of the replica
* @return null if term of {@code coreNodeName} is already maximum
*/
@@ -201,12 +209,12 @@ public class ShardTerms implements MapWriter {
/**
* Mark {@code coreNodeName} as recovering
+ *
* @param coreNodeName of the replica
* @return null if {@code coreNodeName} is already marked as doing recovering
*/
public ShardTerms startRecovering(String coreNodeName) {
- if (values.get(coreNodeName) == maxTerm)
- return null;
+ if (values.get(coreNodeName) == maxTerm) return null;
HashMap<String, Long> newValues = new HashMap<>(values);
if (!newValues.containsKey(recoveringTerm(coreNodeName))) {
@@ -220,6 +228,7 @@ public class ShardTerms implements MapWriter {
/**
* Mark {@code coreNodeName} as finished recovering
+ *
* @param coreNodeName of the replica
* @return null if term of {@code coreNodeName} is already finished doing recovering
*/
@@ -239,10 +248,7 @@ public class ShardTerms implements MapWriter {
@Override
public String toString() {
- return "Terms{" +
- "values=" + values +
- ", version=" + version +
- '}';
+ return "Terms{" + "values=" + values + ", version=" + version + '}';
}
public int getVersion() {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SocketProxy.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SocketProxy.java
index 84baeeb..7e0b480 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SocketProxy.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SocketProxy.java
@@ -32,16 +32,14 @@ import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-
import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.SSLSocketFactory;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Kindly borrowed the idea and base implementation from the ActiveMQ project;
- * useful for blocking traffic on a specified port.
+ * Kindly borrowed the idea and base implementation from the ActiveMQ project; useful for blocking
+ * traffic on a specified port.
*/
public class SocketProxy {
@@ -76,7 +74,7 @@ public class SocketProxy {
this(0, false);
}
- public SocketProxy( boolean useSSL) throws Exception {
+ public SocketProxy(boolean useSSL) throws Exception {
this(0, useSSL);
}
@@ -99,7 +97,7 @@ public class SocketProxy {
}
public String toString() {
- return "SocketyProxy: port="+listenPort+"; target="+target;
+ return "SocketyProxy: port=" + listenPort + "; target=" + target;
}
public void setReceiveBufferSize(int receiveBufferSize) {
@@ -116,8 +114,7 @@ public class SocketProxy {
if (pauseAtStart) {
acceptor.pause();
}
- new Thread(null, acceptor, "SocketProxy-Acceptor-"
- + serverSocket.getLocalPort()).start();
+ new Thread(null, acceptor, "SocketProxy-Acceptor-" + serverSocket.getLocalPort()).start();
closed = new CountDownLatch(1);
}
@@ -175,8 +172,7 @@ public class SocketProxy {
}
}
- public boolean waitUntilClosed(long timeoutSeconds)
- throws InterruptedException {
+ public boolean waitUntilClosed(long timeoutSeconds) throws InterruptedException {
return closed.await(timeoutSeconds, TimeUnit.SECONDS);
}
@@ -268,12 +264,17 @@ public class SocketProxy {
this.acceptBacklog = acceptBacklog;
}
- private URI urlFromSocket(URI uri, ServerSocket serverSocket)
- throws Exception {
+ private URI urlFromSocket(URI uri, ServerSocket serverSocket) throws Exception {
int listenPort = serverSocket.getLocalPort();
- return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(),
- listenPort, uri.getPath(), uri.getQuery(), uri.getFragment());
+ return new URI(
+ uri.getScheme(),
+ uri.getUserInfo(),
+ uri.getHost(),
+ listenPort,
+ uri.getPath(),
+ uri.getQuery(),
+ uri.getFragment());
}
public class Bridge {
@@ -289,11 +290,13 @@ public class SocketProxy {
if (receiveBufferSize > 0) {
sendSocket.setReceiveBufferSize(receiveBufferSize);
}
- sendSocket.connect(new InetSocketAddress(target.getHost(), target
- .getPort()));
+ sendSocket.connect(new InetSocketAddress(target.getHost(), target.getPort()));
linkWithThreads(receiveSocket, sendSocket);
if (log.isInfoEnabled()) {
- log.info("proxy connection {}, receiveBufferSize={}", sendSocket, sendSocket.getReceiveBufferSize());
+ log.info(
+ "proxy connection {}, receiveBufferSize={}",
+ sendSocket,
+ sendSocket.getReceiveBufferSize());
}
}
@@ -333,8 +336,7 @@ public class SocketProxy {
private AtomicReference<CountDownLatch> pause = new AtomicReference<CountDownLatch>();
public Pump(String kind, Socket source, Socket dest) {
- super("SocketProxy-"+kind+"-" + source.getPort() + ":"
- + dest.getPort());
+ super("SocketProxy-" + kind + "-" + source.getPort() + ":" + dest.getPort());
src = source;
destination = dest;
pause.set(new CountDownLatch(0));
@@ -358,7 +360,7 @@ public class SocketProxy {
log.warn("Failed to set socket timeout on {} due to: ", src, e);
return;
}
- log.error("Failed to set socket timeout on {} due to ",src, e);
+ log.error("Failed to set socket timeout on {} due to ", src, e);
throw new RuntimeException(e);
}
@@ -380,8 +382,7 @@ public class SocketProxy {
break;
}
pause.get().await();
- if (len > 0)
- out.write(buf, 0, len);
+ if (len > 0) out.write(buf, 0, len);
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
@@ -393,7 +394,8 @@ public class SocketProxy {
// remote end will see a close at the same time.
close();
}
- } catch (Exception ignore) {}
+ } catch (Exception ignore) {
+ }
} finally {
if (in != null) {
try {
@@ -451,7 +453,8 @@ public class SocketProxy {
synchronized (connections) {
connections.add(new Bridge(source, target));
}
- } catch (SocketTimeoutException expected) {}
+ } catch (SocketTimeoutException expected) {
+ }
}
} catch (Exception e) {
if (log.isDebugEnabled()) {
@@ -465,8 +468,8 @@ public class SocketProxy {
socket.close();
closed.countDown();
goOn();
- } catch (IOException ignored) {}
+ } catch (IOException ignored) {
+ }
}
}
-
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SolrCloudManager.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SolrCloudManager.java
index 3e7af6d..e682c16 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SolrCloudManager.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/SolrCloudManager.java
@@ -19,7 +19,6 @@ package org.apache.solr.client.solrj.cloud;
import java.io.IOException;
import java.util.Map;
-
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrResponse;
import org.apache.solr.client.solrj.impl.ClusterStateProvider;
@@ -28,9 +27,11 @@ import org.apache.solr.common.util.ObjectCache;
import org.apache.solr.common.util.TimeSource;
/**
- * This interface abstracts the access to a SolrCloud cluster, including interactions with Zookeeper, Solr
- * and generic HTTP calls.
- * <p>This abstraction should be used when possible instead of directly referencing ZK, Solr and HTTP.</p>
+ * This interface abstracts the access to a SolrCloud cluster, including interactions with
+ * Zookeeper, Solr and generic HTTP calls.
+ *
+ * <p>This abstraction should be used when possible instead of directly referencing ZK, Solr and
+ * HTTP.
*/
public interface SolrCloudManager extends SolrCloseable {
@@ -50,5 +51,12 @@ public interface SolrCloudManager extends SolrCloseable {
<T extends SolrResponse> T request(SolrRequest<T> req) throws IOException;
- byte[] httpRequest(String url, SolrRequest.METHOD method, Map<String, String> headers, String payload, int timeout, boolean followRedirects) throws IOException;
+ byte[] httpRequest(
+ String url,
+ SolrRequest.METHOD method,
+ Map<String, String> headers,
+ String payload,
+ int timeout,
+ boolean followRedirects)
+ throws IOException;
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/VersionedData.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/VersionedData.java
index 003bb83..ef8aa61 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/VersionedData.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/VersionedData.java
@@ -20,14 +20,11 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Base64;
import java.util.Objects;
-
import org.apache.solr.common.MapWriter;
import org.apache.solr.common.util.Utils;
import org.apache.zookeeper.CreateMode;
-/**
- * Immutable representation of binary data with version.
- */
+/** Immutable representation of binary data with version. */
public class VersionedData implements MapWriter {
private final int version;
private final byte[] data;
@@ -36,6 +33,7 @@ public class VersionedData implements MapWriter {
/**
* Constructor.
+ *
* @param version version of the data, or -1 if unknown
* @param data binary data, or null.
* @param mode create mode
@@ -86,10 +84,10 @@ public class VersionedData implements MapWriter {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
VersionedData that = (VersionedData) o;
- return version == that.version &&
- Arrays.equals(data, that.data) &&
- Objects.equals(owner, that.owner) &&
- mode == that.mode;
+ return version == that.version
+ && Arrays.equals(data, that.data)
+ && Objects.equals(owner, that.owner)
+ && mode == that.mode;
}
@Override
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/package-info.java b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/package-info.java
index 0ce8a66..4f4add2 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/package-info.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/cloud/package-info.java
@@ -15,9 +15,5 @@
* limitations under the License.
*/
-/**
- * Common classes for SolrCloud.
- */
-
+/** Common classes for SolrCloud. */
package org.apache.solr.client.solrj.cloud;
-
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/embedded/SSLConfig.java b/solr/solrj/src/java/org/apache/solr/client/solrj/embedded/SSLConfig.java
index 10066e3..0acb439 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/embedded/SSLConfig.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/embedded/SSLConfig.java
@@ -18,9 +18,10 @@ package org.apache.solr.client.solrj.embedded;
import org.eclipse.jetty.util.ssl.SslContextFactory;
-/**
- * Encapsulates settings related to SSL Configuration.
- * NOTE: all other settings are ignored if {@link #isSSLMode} is false.
+/**
+ * Encapsulates settings related to SSL Configuration. NOTE: all other settings are ignored if
+ * {@link #isSSLMode} is false.
+ *
* @see #setUseSSL
*/
public class SSLConfig {
@@ -31,8 +32,17 @@ public class SSLConfig {
private String trustStore;
private String trustStorePassword;
- /** NOTE: all other settings are ignored if useSsl is false; trustStore settings are ignored if clientAuth is false */
- public SSLConfig(boolean useSsl, boolean clientAuth, String keyStore, String keyStorePassword, String trustStore, String trustStorePassword) {
+ /**
+ * NOTE: all other settings are ignored if useSsl is false; trustStore settings are ignored if
+ * clientAuth is false
+ */
+ public SSLConfig(
+ boolean useSsl,
+ boolean clientAuth,
+ String keyStore,
+ String keyStorePassword,
+ String trustStore,
+ String trustStorePassword) {
this.useSsl = useSsl;
this.clientAuth = clientAuth;
this.keyStore = keyStore;
@@ -40,20 +50,20 @@ public class SSLConfig {
this.trustStore = trustStore;
this.trustStorePassword = trustStorePassword;
}
-
+
public void setUseSSL(boolean useSsl) {
this.useSsl = useSsl;
}
-
+
public void setClientAuth(boolean clientAuth) {
this.clientAuth = clientAuth;
}
-
+
/** All other settings on this object are ignored unless this is true */
public boolean isSSLMode() {
return useSsl;
}
-
+
public boolean isClientAuthMode() {
return clientAuth;
}
@@ -75,16 +85,16 @@ public class SSLConfig {
}
/**
- * Returns an SslContextFactory.Server that should be used by a jetty server based on the specified
- * SSLConfig param which may be null.
+ * Returns an SslContextFactory.Server that should be used by a jetty server based on the
+ * specified SSLConfig param which may be null.
+ *
+ * <p>if the SSLConfig param is non-null, then this method will return the results of {@link
+ * #createContextFactory()}.
+ *
+ * <p>If the SSLConfig param is null, then this method will return null unless the <code>
+ * tests.jettySsl</code> system property is true, in which case standard "javax.net.ssl.*" system
+ * properties will be used instead, along with "tests.jettySsl.clientAuth".
*
- * if the SSLConfig param is non-null, then this method will return the results of
- * {@link #createContextFactory()}.
- *
- * If the SSLConfig param is null, then this method will return null unless the
- * <code>tests.jettySsl</code> system property is true, in which case standard "javax.net.ssl.*"
- * system properties will be used instead, along with "tests.jettySsl.clientAuth".
- *
* @see #createContextFactory()
*/
public static SslContextFactory.Server createContextFactory(SSLConfig sslConfig) {
@@ -98,12 +108,12 @@ public class SSLConfig {
// else...
return null;
}
-
+
/**
- * Returns an SslContextFactory.Server that should be used by a jetty server based on this SSLConfig instance,
- * or null if SSL should not be used.
+ * Returns an SslContextFactory.Server that should be used by a jetty server based on this
+ * SSLConfig instance, or null if SSL should not be used.
*
- * The default implementation generates a simple factory according to the keystore, truststore,
+ * <p>The default implementation generates a simple factory according to the keystore, truststore,
* and clientAuth properties of this object.
*
* @see #getKeyStore
@@ -113,30 +123,26 @@ public class SSLConfig {
* @see #getTrustStorePassword
*/
public SslContextFactory.Server createContextFactory() {
- if (! isSSLMode()) {
+ if (!isSSLMode()) {
return null;
}
// else...
-
+
SslContextFactory.Server factory = new SslContextFactory.Server();
- if (getKeyStore() != null)
- factory.setKeyStorePath(getKeyStore());
- if (getKeyStorePassword() != null)
- factory.setKeyStorePassword(getKeyStorePassword());
-
+ if (getKeyStore() != null) factory.setKeyStorePath(getKeyStore());
+ if (getKeyStorePassword() != null) factory.setKeyStorePassword(getKeyStorePassword());
+
factory.setNeedClientAuth(isClientAuthMode());
-
+
if (isClientAuthMode()) {
- if (getTrustStore() != null)
- factory.setTrustStorePath(getTrustStore());
- if (getTrustStorePassword() != null)
- factory.setTrustStorePassword(getTrustStorePassword());
+ if (getTrustStore() != null) factory.setTrustStorePath(getTrustStore());
+ if (getTrustStorePassword() != null) factory.setTrustStorePassword(getTrustStorePassword());
}
return factory;
}
public SslContextFactory.Client createClientContextFactory() {
- if (! isSSLMode()) {
+ if (!isSSLMode()) {
return null;
}
// else...
@@ -150,10 +156,8 @@ public class SSLConfig {
}
if (isClientAuthMode()) {
- if (getTrustStore() != null)
- factory.setTrustStorePath(getTrustStore());
- if (getTrustStorePassword() != null)
- factory.setTrustStorePassword(getTrustStorePassword());
+ if (getTrustStore() != null) factory.setTrustStorePath(getTrustStore());
+ if (getTrustStorePassword() != null) factory.setTrustStorePassword(getTrustStorePassword());
}
return factory;
@@ -163,20 +167,16 @@ public class SSLConfig {
SslContextFactory.Server sslcontext = new SslContextFactory.Server();
if (null != System.getProperty("javax.net.ssl.keyStore")) {
- sslcontext.setKeyStorePath
- (System.getProperty("javax.net.ssl.keyStore"));
+ sslcontext.setKeyStorePath(System.getProperty("javax.net.ssl.keyStore"));
}
if (null != System.getProperty("javax.net.ssl.keyStorePassword")) {
- sslcontext.setKeyStorePassword
- (System.getProperty("javax.net.ssl.keyStorePassword"));
+ sslcontext.setKeyStorePassword(System.getProperty("javax.net.ssl.keyStorePassword"));
}
if (null != System.getProperty("javax.net.ssl.trustStore")) {
- sslcontext.setTrustStorePath
- (System.getProperty("javax.net.ssl.trustStore"));
+ sslcontext.setTrustStorePath(System.getProperty("javax.net.ssl.trustStore"));
}
if (null != System.getProperty("javax.net.ssl.trustStorePassword")) {
- sslcontext.setTrustStorePassword
- (System.getProperty("javax.net.ssl.trustStorePassword"));
+ sslcontext.setTrustStorePassword(System.getProperty("javax.net.ssl.trustStorePassword"));
}
sslcontext.setNeedClientAuth(Boolean.getBoolean("tests.jettySsl.clientAuth"));
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
index f1ed495..163b34e 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
@@ -17,6 +17,9 @@
package org.apache.solr.client.solrj.impl;
+import static org.apache.solr.common.params.CommonParams.ADMIN_PATHS;
+import static org.apache.solr.common.params.CommonParams.ID;
+
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.net.ConnectException;
@@ -45,7 +48,6 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
-
import org.apache.solr.client.solrj.ResponseParser;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
@@ -88,28 +90,27 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-import static org.apache.solr.common.params.CommonParams.ADMIN_PATHS;
-import static org.apache.solr.common.params.CommonParams.ID;
-
public abstract class BaseCloudSolrClient extends SolrClient {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private volatile String defaultCollection;
- //no of times collection state to be reloaded if stale state error is received
- private static final int MAX_STALE_RETRIES = Integer.parseInt(System.getProperty("cloudSolrClientMaxStaleRetries", "5"));
+ // no of times collection state to be reloaded if stale state error is received
+ private static final int MAX_STALE_RETRIES =
+ Integer.parseInt(System.getProperty("cloudSolrClientMaxStaleRetries", "5"));
private Random rand = new Random();
private final boolean updatesToLeaders;
private final boolean directUpdatesToLeadersOnly;
private final RequestReplicaListTransformerGenerator requestRLTGenerator;
- boolean parallelUpdates; //TODO final
- private ExecutorService threadPool = ExecutorUtil
- .newMDCAwareCachedThreadPool(new SolrNamedThreadFactory(
- "CloudSolrClient ThreadPool"));
+ boolean parallelUpdates; // TODO final
+ private ExecutorService threadPool =
+ ExecutorUtil.newMDCAwareCachedThreadPool(
+ new SolrNamedThreadFactory("CloudSolrClient ThreadPool"));
public static final String STATE_VERSION = "_stateVer_";
- private long retryExpiryTime = TimeUnit.NANOSECONDS.convert(3, TimeUnit.SECONDS);//3 seconds or 3 million nanos
+ private long retryExpiryTime =
+ TimeUnit.NANOSECONDS.convert(3, TimeUnit.SECONDS); // 3 seconds or 3 million nanos
private final Set<String> NON_ROUTABLE_PARAMS;
{
@@ -128,8 +129,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// NON_ROUTABLE_PARAMS.add(UpdateParams.ROLLBACK);
}
- private volatile List<Object> locks = objectList(3);
+ private volatile List<Object> locks = objectList(3);
static class StateCache extends ConcurrentHashMap<String, ExpiringCachedDocCollection> {
final AtomicLong puts = new AtomicLong();
@@ -140,13 +141,13 @@ public abstract class BaseCloudSolrClient extends SolrClient {
@Override
public ExpiringCachedDocCollection get(Object key) {
ExpiringCachedDocCollection val = super.get(key);
- if(val == null) {
+ if (val == null) {
// a new collection is likely to be added now.
- //check if there are stale items and remove them
+ // check if there are stale items and remove them
evictStale();
return null;
}
- if(val.isExpired(timeToLive)) {
+ if (val.isExpired(timeToLive)) {
super.remove(key);
return null;
}
@@ -161,10 +162,10 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
void evictStale() {
- if(!evictLock.tryLock()) return;
+ if (!evictLock.tryLock()) return;
try {
for (Entry<String, ExpiringCachedDocCollection> e : entrySet()) {
- if(e.getValue().isExpired(timeToLive)){
+ if (e.getValue().isExpired(timeToLive)) {
super.remove(e.getKey());
}
}
@@ -172,14 +173,12 @@ public abstract class BaseCloudSolrClient extends SolrClient {
evictLock.unlock();
}
}
-
}
/**
- * This is the time to wait to refetch the state
- * after getting the same state version from ZK
- * <p>
- * secs
+ * This is the time to wait to refetch the state after getting the same state version from ZK
+ *
+ * <p>secs
*/
public void setRetryExpiryTime(int secs) {
this.retryExpiryTime = TimeUnit.NANOSECONDS.convert(secs, TimeUnit.SECONDS);
@@ -190,9 +189,9 @@ public abstract class BaseCloudSolrClient extends SolrClient {
class ExpiringCachedDocCollection {
final DocCollection cached;
final long cachedAt;
- //This is the time at which the collection is retried and got the same old version
+ // This is the time at which the collection is retried and got the same old version
volatile long retriedAt = -1;
- //flag that suggests that this is potentially to be rechecked
+ // flag that suggests that this is potentially to be rechecked
volatile boolean maybeStale = false;
ExpiringCachedDocCollection(DocCollection cached) {
@@ -206,11 +205,10 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
boolean shouldRetry() {
- if (maybeStale) {// we are not sure if it is stale so check with retry time
- if ((retriedAt == -1 ||
- (System.nanoTime() - retriedAt) > retryExpiryTime)) {
- return true;// we retried a while back. and we could not get anything new.
- //it's likely that it is not going to be available now also.
+ if (maybeStale) { // we are not sure if it is stale so check with retry time
+ if ((retriedAt == -1 || (System.nanoTime() - retriedAt) > retryExpiryTime)) {
+ return true; // we retried a while back. and we could not get anything new.
+ // it's likely that it is not going to be available now also.
}
}
return false;
@@ -221,17 +219,20 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
}
- protected BaseCloudSolrClient(boolean updatesToLeaders, boolean parallelUpdates, boolean directUpdatesToLeadersOnly) {
+ protected BaseCloudSolrClient(
+ boolean updatesToLeaders, boolean parallelUpdates, boolean directUpdatesToLeadersOnly) {
this.updatesToLeaders = updatesToLeaders;
this.parallelUpdates = parallelUpdates;
this.directUpdatesToLeadersOnly = directUpdatesToLeadersOnly;
this.requestRLTGenerator = new RequestReplicaListTransformerGenerator();
}
- /** Sets the cache ttl for DocCollection Objects cached.
+ /**
+ * Sets the cache ttl for DocCollection Objects cached.
+ *
* @param seconds ttl value in seconds
*/
- public void setCollectionCacheTTl(int seconds){
+ public void setCollectionCacheTTl(int seconds) {
assert seconds > 0;
this.collectionStateCache.timeToLive = seconds * 1000L;
}
@@ -244,7 +245,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
@Override
public void close() throws IOException {
- if(this.threadPool != null && !this.threadPool.isShutdown()) {
+ if (this.threadPool != null && !this.threadPool.isShutdown()) {
this.threadPool.shutdown();
}
}
@@ -256,9 +257,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
/**
* Note: This setter method is <b>not thread-safe</b>.
*
- * @param processor
- * Default Response Parser chosen to parse the response if the parser
- * were not specified as part of the request.
+ * @param processor Default Response Parser chosen to parse the response if the parser were not
+ * specified as part of the request.
* @see org.apache.solr.client.solrj.SolrRequest#getResponseParser()
*/
public void setParser(ResponseParser processor) {
@@ -273,16 +273,15 @@ public abstract class BaseCloudSolrClient extends SolrClient {
getLbClient().setRequestWriter(requestWriter);
}
- /**
- * @return the zkHost value used to connect to zookeeper.
- */
+ /** @return the zkHost value used to connect to zookeeper. */
public String getZkHost() {
return assertZKStateProvider().zkHost;
}
public ZkStateReader getZkStateReader() {
if (getClusterStateProvider() instanceof ZkClientClusterStateProvider) {
- ZkClientClusterStateProvider provider = (ZkClientClusterStateProvider) getClusterStateProvider();
+ ZkClientClusterStateProvider provider =
+ (ZkClientClusterStateProvider) getClusterStateProvider();
getClusterStateProvider().connect();
return provider.zkStateReader;
}
@@ -315,23 +314,29 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
/**
- * Connect to the zookeeper ensemble.
- * This is an optional method that may be used to force a connect before any other requests are sent.
+ * Connect to the zookeeper ensemble. This is an optional method that may be used to force a
+ * connect before any other requests are sent.
*/
public void connect() {
getClusterStateProvider().connect();
}
/**
- * Connect to a cluster. If the cluster is not ready, retry connection up to a given timeout.
+ * Connect to a cluster. If the cluster is not ready, retry connection up to a given timeout.
+ *
* @param duration the timeout
* @param timeUnit the units of the timeout
* @throws TimeoutException if the cluster is not ready after the timeout
* @throws InterruptedException if the wait is interrupted
*/
- public void connect(long duration, TimeUnit timeUnit) throws TimeoutException, InterruptedException {
+ public void connect(long duration, TimeUnit timeUnit)
+ throws TimeoutException, InterruptedException {
if (log.isInfoEnabled()) {
- log.info("Waiting for {} {} for cluster at {} to be ready", duration, timeUnit, getClusterStateProvider());
+ log.info(
+ "Waiting for {} {} for cluster at {} to be ready",
+ duration,
+ timeUnit,
+ getClusterStateProvider());
}
long timeout = System.nanoTime() + timeUnit.toNanos(duration);
while (System.nanoTime() < timeout) {
@@ -341,8 +346,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
log.info("Cluster at {} ready", getClusterStateProvider());
}
return;
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
// not ready yet, then...
}
TimeUnit.MILLISECONDS.sleep(250);
@@ -355,33 +359,28 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return (ZkClientClusterStateProvider) getClusterStateProvider();
}
throw new IllegalArgumentException("This client does not use ZK");
-
}
/**
* Block until a CollectionStatePredicate returns true, or the wait times out
*
- * <p>
- * Note that the predicate may be called again even after it has returned true, so
- * implementors should avoid changing state within the predicate call itself.
- * </p>
+ * <p>Note that the predicate may be called again even after it has returned true, so implementors
+ * should avoid changing state within the predicate call itself.
*
- * <p>
- * This implementation utilizes {@link CollectionStateWatcher} internally.
- * Callers that don't care about liveNodes are encouraged to use a {@link DocCollection} {@link Predicate}
- * instead
- * </p>
+ * <p>This implementation utilizes {@link CollectionStateWatcher} internally. Callers that don't
+ * care about liveNodes are encouraged to use a {@link DocCollection} {@link Predicate} instead
*
* @see #waitForState(String, long, TimeUnit, Predicate)
* @see #registerCollectionStateWatcher
* @param collection the collection to watch
- * @param wait how long to wait
- * @param unit the units of the wait parameter
- * @param predicate a {@link CollectionStatePredicate} to check the collection state
+ * @param wait how long to wait
+ * @param unit the units of the wait parameter
+ * @param predicate a {@link CollectionStatePredicate} to check the collection state
* @throws InterruptedException on interrupt
- * @throws TimeoutException on timeout
+ * @throws TimeoutException on timeout
*/
- public void waitForState(String collection, long wait, TimeUnit unit, CollectionStatePredicate predicate)
+ public void waitForState(
+ String collection, long wait, TimeUnit unit, CollectionStatePredicate predicate)
throws InterruptedException, TimeoutException {
getClusterStateProvider().connect();
assertZKStateProvider().zkStateReader.waitForState(collection, wait, unit, predicate);
@@ -389,20 +388,19 @@ public abstract class BaseCloudSolrClient extends SolrClient {
/**
* Block until a Predicate returns true, or the wait times out
*
- * <p>
- * Note that the predicate may be called again even after it has returned true, so
- * implementors should avoid changing state within the predicate call itself.
- * </p>
+ * <p>Note that the predicate may be called again even after it has returned true, so implementors
+ * should avoid changing state within the predicate call itself.
*
* @see #registerDocCollectionWatcher
* @param collection the collection to watch
- * @param wait how long to wait
- * @param unit the units of the wait parameter
- * @param predicate a {@link Predicate} to test against the {@link DocCollection}
+ * @param wait how long to wait
+ * @param unit the units of the wait parameter
+ * @param predicate a {@link Predicate} to test against the {@link DocCollection}
* @throws InterruptedException on interrupt
- * @throws TimeoutException on timeout
+ * @throws TimeoutException on timeout
*/
- public void waitForState(String collection, long wait, TimeUnit unit, Predicate<DocCollection> predicate)
+ public void waitForState(
+ String collection, long wait, TimeUnit unit, Predicate<DocCollection> predicate)
throws InterruptedException, TimeoutException {
getClusterStateProvider().connect();
assertZKStateProvider().zkStateReader.waitForState(collection, wait, unit, predicate);
@@ -412,38 +410,32 @@ public abstract class BaseCloudSolrClient extends SolrClient {
* Register a CollectionStateWatcher to be called when the cluster state for a collection changes
* <em>or</em> the set of live nodes changes.
*
- * <p>
- * The Watcher will automatically be removed when it's
- * <code>onStateChanged</code> returns <code>true</code>
- * </p>
+ * <p>The Watcher will automatically be removed when it's <code>onStateChanged</code> returns
+ * <code>true</code>
*
- * <p>
- * This implementation utilizes {@link ZkStateReader#registerCollectionStateWatcher} internally.
- * Callers that don't care about liveNodes are encouraged to use a {@link DocCollectionWatcher}
- * instead
- * </p>
+ * <p>This implementation utilizes {@link ZkStateReader#registerCollectionStateWatcher}
+ * internally. Callers that don't care about liveNodes are encouraged to use a {@link
+ * DocCollectionWatcher} instead
*
* @see #registerDocCollectionWatcher(String, DocCollectionWatcher)
* @see ZkStateReader#registerCollectionStateWatcher
* @param collection the collection to watch
- * @param watcher a watcher that will be called when the state changes
+ * @param watcher a watcher that will be called when the state changes
*/
public void registerCollectionStateWatcher(String collection, CollectionStateWatcher watcher) {
getClusterStateProvider().connect();
assertZKStateProvider().zkStateReader.registerCollectionStateWatcher(collection, watcher);
}
-
+
/**
* Register a DocCollectionWatcher to be called when the cluster state for a collection changes.
*
- * <p>
- * The Watcher will automatically be removed when it's
- * <code>onStateChanged</code> returns <code>true</code>
- * </p>
+ * <p>The Watcher will automatically be removed when it's <code>onStateChanged</code> returns
+ * <code>true</code>
*
* @see ZkStateReader#registerDocCollectionWatcher
* @param collection the collection to watch
- * @param watcher a watcher that will be called when the state changes
+ * @param watcher a watcher that will be called when the state changes
*/
public void registerDocCollectionWatcher(String collection, DocCollectionWatcher watcher) {
getClusterStateProvider().connect();
@@ -451,16 +443,17 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
@SuppressWarnings({"unchecked"})
- private NamedList<Object> directUpdate(AbstractUpdateRequest request, String collection) throws SolrServerException {
+ private NamedList<Object> directUpdate(AbstractUpdateRequest request, String collection)
+ throws SolrServerException {
UpdateRequest updateRequest = (UpdateRequest) request;
SolrParams params = request.getParams();
ModifiableSolrParams routableParams = new ModifiableSolrParams();
ModifiableSolrParams nonRoutableParams = new ModifiableSolrParams();
- if(params != null) {
+ if (params != null) {
nonRoutableParams.add(params);
routableParams.add(params);
- for(String param : NON_ROUTABLE_PARAMS) {
+ for (String param : NON_ROUTABLE_PARAMS) {
routableParams.remove(param);
}
} else {
@@ -468,17 +461,22 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
if (collection == null) {
- throw new SolrServerException("No collection param specified on request and no default collection has been set.");
+ throw new SolrServerException(
+ "No collection param specified on request and no default collection has been set.");
}
- //Check to see if the collection is an alias. Updates to multi-collection aliases are ok as long
- // as they are routed aliases
+ // Check to see if the collection is an alias. Updates to multi-collection aliases are ok as
+ // long as they are routed aliases
List<String> aliasedCollections = getClusterStateProvider().resolveAlias(collection);
if (getClusterStateProvider().isRoutedAlias(collection) || aliasedCollections.size() == 1) {
collection = aliasedCollections.get(0); // pick 1st (consistent with HttpSolrCall behavior)
} else {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Update request to non-routed multi-collection alias not supported: "
- + collection + " -> " + aliasedCollections);
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST,
+ "Update request to non-routed multi-collection alias not supported: "
+ + collection
+ + " -> "
+ + aliasedCollections);
}
DocCollection col = getDocCollection(collection, null);
@@ -490,19 +488,23 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return null;
}
- ReplicaListTransformer replicaListTransformer = requestRLTGenerator.getReplicaListTransformer(params);
+ ReplicaListTransformer replicaListTransformer =
+ requestRLTGenerator.getReplicaListTransformer(params);
- //Create the URL map, which is keyed on slice name.
- //The value is a list of URLs for each replica in the slice.
- //The first value in the list is the leader for the slice.
+ // Create the URL map, which is keyed on slice name.
+ // The value is a list of URLs for each replica in the slice.
+ // The first value in the list is the leader for the slice.
final Map<String, List<String>> urlMap = buildUrlMap(col, replicaListTransformer);
- String routeField = (col.getRouter().getRouteField(col) == null) ? ID : col.getRouter().getRouteField(col);
- final Map<String, ? extends LBSolrClient.Req> routes = createRoutes(updateRequest, routableParams, col, router, urlMap, routeField);
+ String routeField =
+ (col.getRouter().getRouteField(col) == null) ? ID : col.getRouter().getRouteField(col);
+ final Map<String, ? extends LBSolrClient.Req> routes =
+ createRoutes(updateRequest, routableParams, col, router, urlMap, routeField);
if (routes == null) {
if (directUpdatesToLeadersOnly && hasInfoToFindLeaders(updateRequest, routeField)) {
// we have info (documents with ids and/or ids to delete) with
// which to find the leaders but we could not find (all of) them
- throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE,
+ throw new SolrException(
+ SolrException.ErrorCode.SERVICE_UNAVAILABLE,
"directUpdatesToLeadersOnly==true but could not find leader(s)");
} else {
// we could not find a leader or routes yet - use unoptimized general path
@@ -511,7 +513,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
final NamedList<Throwable> exceptions = new NamedList<>();
- final NamedList<NamedList<?>> shardResponses = new NamedList<>(routes.size()+1); // +1 for deleteQuery
+ final NamedList<NamedList<?>> shardResponses =
+ new NamedList<>(routes.size() + 1); // +1 for deleteQuery
long start = System.nanoTime();
@@ -522,15 +525,18 @@ public abstract class BaseCloudSolrClient extends SolrClient {
final LBSolrClient.Req lbRequest = entry.getValue();
try {
MDC.put("CloudSolrClient.url", url);
- responseFutures.put(url, threadPool.submit(() -> {
- return getLbClient().request(lbRequest).getResponse();
- }));
+ responseFutures.put(
+ url,
+ threadPool.submit(
+ () -> {
+ return getLbClient().request(lbRequest).getResponse();
+ }));
} finally {
MDC.remove("CloudSolrClient.url");
}
}
- for (final Map.Entry<String, Future<NamedList<?>>> entry: responseFutures.entrySet()) {
+ for (final Map.Entry<String, Future<NamedList<?>>> entry : responseFutures.entrySet()) {
final String url = entry.getKey();
final Future<NamedList<?>> responseFuture = entry.getValue();
try {
@@ -545,9 +551,10 @@ public abstract class BaseCloudSolrClient extends SolrClient {
if (exceptions.size() > 0) {
Throwable firstException = exceptions.getVal(0);
- if(firstException instanceof SolrException) {
+ if (firstException instanceof SolrException) {
SolrException e = (SolrException) firstException;
- throw getRouteException(SolrException.ErrorCode.getErrorCode(e.code()), exceptions, routes);
+ throw getRouteException(
+ SolrException.ErrorCode.getErrorCode(e.code()), exceptions, routes);
} else {
throw getRouteException(SolrException.ErrorCode.SERVER_ERROR, exceptions, routes);
}
@@ -560,7 +567,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
NamedList<Object> rsp = getLbClient().request(lbRequest).getResponse();
shardResponses.add(url, rsp);
} catch (Exception e) {
- if(e instanceof SolrException) {
+ if (e instanceof SolrException) {
throw (SolrException) e;
} else {
throw new SolrServerException(e);
@@ -587,7 +594,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
nonRoutableRequest = new UpdateRequest();
}
nonRoutableRequest.setParams(nonRoutableParams);
- nonRoutableRequest.setBasicAuthCredentials(request.getBasicAuthUser(), request.getBasicAuthPassword());
+ nonRoutableRequest.setBasicAuthCredentials(
+ request.getBasicAuthUser(), request.getBasicAuthPassword());
List<String> urlList = new ArrayList<>(routes.keySet());
Collections.shuffle(urlList, rand);
LBSolrClient.Req req = new LBSolrClient.Req(nonRoutableRequest, urlList);
@@ -602,23 +610,35 @@ public abstract class BaseCloudSolrClient extends SolrClient {
long end = System.nanoTime();
@SuppressWarnings({"rawtypes"})
- RouteResponse rr = condenseResponse(shardResponses, (int) TimeUnit.MILLISECONDS.convert(end - start, TimeUnit.NANOSECONDS));
+ RouteResponse rr =
+ condenseResponse(
+ shardResponses, (int) TimeUnit.MILLISECONDS.convert(end - start, TimeUnit.NANOSECONDS));
rr.setRouteResponses(shardResponses);
rr.setRoutes(routes);
return rr;
}
- protected RouteException getRouteException(SolrException.ErrorCode serverError, NamedList<Throwable> exceptions, Map<String, ? extends LBSolrClient.Req> routes) {
+ protected RouteException getRouteException(
+ SolrException.ErrorCode serverError,
+ NamedList<Throwable> exceptions,
+ Map<String, ? extends LBSolrClient.Req> routes) {
return new RouteException(serverError, exceptions, routes);
}
- protected Map<String, ? extends LBSolrClient.Req> createRoutes(UpdateRequest updateRequest, ModifiableSolrParams routableParams,
- DocCollection col, DocRouter router, Map<String, List<String>> urlMap,
- String routeField) {
- return urlMap == null ? null : updateRequest.getRoutesToCollection(router, col, urlMap, routableParams, routeField);
+ protected Map<String, ? extends LBSolrClient.Req> createRoutes(
+ UpdateRequest updateRequest,
+ ModifiableSolrParams routableParams,
+ DocCollection col,
+ DocRouter router,
+ Map<String, List<String>> urlMap,
+ String routeField) {
+ return urlMap == null
+ ? null
+ : updateRequest.getRoutesToCollection(router, col, urlMap, routableParams, routeField);
}
- private Map<String,List<String>> buildUrlMap(DocCollection col, ReplicaListTransformer replicaListTransformer) {
+ private Map<String, List<String>> buildUrlMap(
+ DocCollection col, ReplicaListTransformer replicaListTransformer) {
Map<String, List<String>> urlMap = new HashMap<>();
Slice[] slices = col.getActiveSlicesArr();
for (Slice slice : slices) {
@@ -626,9 +646,11 @@ public abstract class BaseCloudSolrClient extends SolrClient {
List<Replica> sortedReplicas = new ArrayList<>();
Replica leader = slice.getLeader();
if (directUpdatesToLeadersOnly && leader == null) {
- for (Replica replica : slice.getReplicas(
- replica -> replica.isActive(getClusterStateProvider().getLiveNodes())
- && replica.getType() == Replica.Type.NRT)) {
+ for (Replica replica :
+ slice.getReplicas(
+ replica ->
+ replica.isActive(getClusterStateProvider().getLiveNodes())
+ && replica.getType() == Replica.Type.NRT)) {
leader = replica;
break;
}
@@ -655,12 +677,14 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// put the leaderUrl first.
sortedReplicas.add(0, leader);
- urlMap.put(name, sortedReplicas.stream().map(Replica::getCoreUrl).collect(Collectors.toList()));
+ urlMap.put(
+ name, sortedReplicas.stream().map(Replica::getCoreUrl).collect(Collectors.toList()));
}
return urlMap;
}
- protected <T extends RouteResponse<?>> T condenseResponse(NamedList<?> response, int timeMillis, Supplier<T> supplier) {
+ protected <T extends RouteResponse<?>> T condenseResponse(
+ NamedList<?> response, int timeMillis, Supplier<T> supplier) {
T condensed = supplier.get();
int status = 0;
Integer rf = null;
@@ -672,19 +696,18 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// For "adds", "deletes", "deleteByQuery" etc.
Map<String, NamedList<Object>> versions = new HashMap<>();
- for(int i=0; i<response.size(); i++) {
- NamedList<?> shardResponse = (NamedList<?>)response.getVal(i);
- NamedList<?> header = (NamedList<?>)shardResponse.get("responseHeader");
- Integer shardStatus = (Integer)header.get("status");
+ for (int i = 0; i < response.size(); i++) {
+ NamedList<?> shardResponse = (NamedList<?>) response.getVal(i);
+ NamedList<?> header = (NamedList<?>) shardResponse.get("responseHeader");
+ Integer shardStatus = (Integer) header.get("status");
int s = shardStatus.intValue();
- if(s > 0) {
+ if (s > 0) {
status = s;
}
Object rfObj = header.get(UpdateRequest.REPFACT);
if (rfObj != null && rfObj instanceof Integer) {
- Integer routeRf = (Integer)rfObj;
- if (rf == null || routeRf < rf)
- rf = routeRf;
+ Integer routeRf = (Integer) rfObj;
+ if (rf == null || routeRf < rf) rf = routeRf;
}
@SuppressWarnings("unchecked")
@@ -692,11 +715,14 @@ public abstract class BaseCloudSolrClient extends SolrClient {
(List<SimpleOrderedMap<String>>) header.get("errors");
if (null != shardTolerantErrors) {
Integer shardMaxToleratedErrors = (Integer) header.get("maxErrors");
- assert null != shardMaxToleratedErrors : "TolerantUpdateProcessor reported errors but not maxErrors";
+ assert null != shardMaxToleratedErrors
+ : "TolerantUpdateProcessor reported errors but not maxErrors";
// if we get into some weird state where the nodes disagree about the effective maxErrors,
// assume the min value seen to decide if we should fail.
- maxToleratedErrors = Math.min(maxToleratedErrors,
- ToleratedUpdateError.getEffectiveMaxErrors(shardMaxToleratedErrors.intValue()));
+ maxToleratedErrors =
+ Math.min(
+ maxToleratedErrors,
+ ToleratedUpdateError.getEffectiveMaxErrors(shardMaxToleratedErrors.intValue()));
if (null == toleratedErrors) {
toleratedErrors = new ArrayList<SimpleOrderedMap<String>>(shardTolerantErrors.size());
@@ -705,11 +731,11 @@ public abstract class BaseCloudSolrClient extends SolrClient {
toleratedErrors.add(err);
}
}
- for (String updateType: Arrays.asList("adds", "deletes", "deleteByQuery")) {
+ for (String updateType : Arrays.asList("adds", "deletes", "deleteByQuery")) {
Object obj = shardResponse.get(updateType);
if (obj instanceof NamedList) {
- NamedList<Object> versionsList = versions.containsKey(updateType) ?
- versions.get(updateType): new NamedList<>();
+ NamedList<Object> versionsList =
+ versions.containsKey(updateType) ? versions.get(updateType) : new NamedList<>();
NamedList<?> nl = (NamedList<?>) obj;
versionsList.addAll(nl);
versions.put(updateType, versionsList);
@@ -720,19 +746,20 @@ public abstract class BaseCloudSolrClient extends SolrClient {
NamedList<Object> cheader = new NamedList<>();
cheader.add("status", status);
cheader.add("QTime", timeMillis);
- if (rf != null)
- cheader.add(UpdateRequest.REPFACT, rf);
+ if (rf != null) cheader.add(UpdateRequest.REPFACT, rf);
if (null != toleratedErrors) {
cheader.add("maxErrors", ToleratedUpdateError.getUserFriendlyMaxErrors(maxToleratedErrors));
cheader.add("errors", toleratedErrors);
if (maxToleratedErrors < toleratedErrors.size()) {
// cumulative errors are too high, we need to throw a client exception w/correct metadata
- // NOTE: it shouldn't be possible for 1 == toleratedErrors.size(), because if that were the case
- // then at least one shard should have thrown a real error before this, so we don't worry
- // about having a more "singular" exception msg for that situation
- StringBuilder msgBuf = new StringBuilder()
- .append(toleratedErrors.size()).append(" Async failures during distributed update: ");
+ // NOTE: it shouldn't be possible for 1 == toleratedErrors.size(), because if that were the
+ // case then at least one shard should have thrown a real error before this, so we don't
+ // worry about having a more "singular" exception msg for that situation
+ StringBuilder msgBuf =
+ new StringBuilder()
+ .append(toleratedErrors.size())
+ .append(" Async failures during distributed update: ");
NamedList<String> metadata = new NamedList<>();
for (SimpleOrderedMap<String> err : toleratedErrors) {
@@ -742,7 +769,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
msgBuf.append("\n").append(te.getMessage());
}
- SolrException toThrow = new SolrException(SolrException.ErrorCode.BAD_REQUEST, msgBuf.toString());
+ SolrException toThrow =
+ new SolrException(SolrException.ErrorCode.BAD_REQUEST, msgBuf.toString());
toThrow.setMetadata(metadata);
throw toThrow;
}
@@ -779,7 +807,6 @@ public abstract class BaseCloudSolrClient extends SolrClient {
public Map<String, T> getRoutes() {
return routes;
}
-
}
public static class RouteException extends SolrException {
@@ -787,7 +814,10 @@ public abstract class BaseCloudSolrClient extends SolrClient {
private NamedList<Throwable> throwables;
private Map<String, ? extends LBSolrClient.Req> routes;
- public RouteException(ErrorCode errorCode, NamedList<Throwable> throwables, Map<String, ? extends LBSolrClient.Req> routes){
+ public RouteException(
+ ErrorCode errorCode,
+ NamedList<Throwable> throwables,
+ Map<String, ? extends LBSolrClient.Req> routes) {
super(errorCode, throwables.getVal(0).getMessage(), throwables.getVal(0));
this.throwables = throwables;
this.routes = routes;
@@ -819,7 +849,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
@Override
- public NamedList<Object> request(SolrRequest<?> request, String collection) throws SolrServerException, IOException {
+ public NamedList<Object> request(SolrRequest<?> request, String collection)
+ throws SolrServerException, IOException {
// the collection parameter of the request overrides that of the parameter to this method
String requestCollection = request.getCollection();
if (requestCollection != null) {
@@ -833,18 +864,20 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
/**
- * As this class doesn't watch external collections on the client side,
- * there's a chance that the request will fail due to cached stale state,
- * which means the state must be refreshed from ZK and retried.
+ * As this class doesn't watch external collections on the client side, there's a chance that the
+ * request will fail due to cached stale state, which means the state must be refreshed from ZK
+ * and retried.
*/
- protected NamedList<Object> requestWithRetryOnStaleState(SolrRequest<?> request, int retryCount, List<String> inputCollections)
+ protected NamedList<Object> requestWithRetryOnStaleState(
+ SolrRequest<?> request, int retryCount, List<String> inputCollections)
throws SolrServerException, IOException {
connect(); // important to call this before you start working with the ZkStateReader
// build up a _stateVer_ param to pass to the server containing all of the
// external collection state versions involved in this request, which allows
// the server to notify us that our cached state for one or more of the external
- // collections is stale and needs to be refreshed ... this code has no impact on internal collections
+ // collections is stale and needs to be refreshed ... this code has no impact on internal
+ // collections
String stateVerParam = null;
List<DocCollection> requestedCollections = null;
boolean isCollectionRequestOfV2 = false;
@@ -856,7 +889,9 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
boolean isAdmin = ADMIN_PATHS.contains(request.getPath());
boolean isUpdate = (request instanceof IsUpdateRequest) && (request instanceof UpdateRequest);
- if (!inputCollections.isEmpty() && !isAdmin && !isCollectionRequestOfV2) { // don't do _stateVer_ checking for admin, v2 api requests
+ if (!inputCollections.isEmpty()
+ && !isAdmin
+ && !isCollectionRequestOfV2) { // don't do _stateVer_ checking for admin, v2 api requests
Set<String> requestedCollectionNames = resolveAliases(inputCollections, isUpdate);
StringBuilder stateVerParamBuilder = null;
@@ -864,16 +899,19 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// track the version of state we're using on the client side using the _stateVer_ param
DocCollection coll = getDocCollection(requestedCollection, null);
if (coll == null) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection not found: " + requestedCollection);
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST, "Collection not found: " + requestedCollection);
}
int collVer = coll.getZNodeVersion();
- if(requestedCollections == null) requestedCollections = new ArrayList<>(requestedCollectionNames.size());
+ if (requestedCollections == null)
+ requestedCollections = new ArrayList<>(requestedCollectionNames.size());
requestedCollections.add(coll);
if (stateVerParamBuilder == null) {
stateVerParamBuilder = new StringBuilder();
} else {
- stateVerParamBuilder.append("|"); // hopefully pipe is not an allowed char in a collection name
+ stateVerParamBuilder.append(
+ "|"); // hopefully pipe is not an allowed char in a collection name
}
stateVerParamBuilder.append(coll.getName()).append(":").append(collVer);
@@ -896,16 +934,17 @@ public abstract class BaseCloudSolrClient extends SolrClient {
NamedList<Object> resp = null;
try {
resp = sendRequest(request, inputCollections);
- //to avoid an O(n) operation we always add STATE_VERSION to the last and try to read it from there
+ // to avoid an O(n) operation we always add STATE_VERSION to the last and try to read it from
+ // there
Object o = resp == null || resp.size() == 0 ? null : resp.get(STATE_VERSION, resp.size() - 1);
- if(o != null && o instanceof Map) {
- //remove this because no one else needs this and tests would fail if they are comparing responses
- resp.remove(resp.size()-1);
- Map<?,?> invalidStates = (Map<?,?>) o;
- for (Map.Entry<?,?> e : invalidStates.entrySet()) {
+ if (o != null && o instanceof Map) {
+ // remove this because no one else needs this and tests would fail if they are comparing
+ // responses
+ resp.remove(resp.size() - 1);
+ Map<?, ?> invalidStates = (Map<?, ?>) o;
+ for (Map.Entry<?, ?> e : invalidStates.entrySet()) {
getDocCollection((String) e.getKey(), (Integer) e.getValue());
}
-
}
} catch (Exception exc) {
@@ -913,30 +952,35 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// don't do retry support for admin requests
// or if the request doesn't have a collection specified
// or request is v2 api and its method is not GET
- if (inputCollections.isEmpty() || isAdmin || (request instanceof V2Request && request.getMethod() != SolrRequest.METHOD.GET)) {
+ if (inputCollections.isEmpty()
+ || isAdmin
+ || (request instanceof V2Request && request.getMethod() != SolrRequest.METHOD.GET)) {
if (exc instanceof SolrServerException) {
- throw (SolrServerException)exc;
+ throw (SolrServerException) exc;
} else if (exc instanceof IOException) {
- throw (IOException)exc;
- }else if (exc instanceof RuntimeException) {
+ throw (IOException) exc;
+ } else if (exc instanceof RuntimeException) {
throw (RuntimeException) exc;
- }
- else {
+ } else {
throw new SolrServerException(rootCause);
}
}
- int errorCode = (rootCause instanceof SolrException) ?
- ((SolrException)rootCause).code() : SolrException.ErrorCode.UNKNOWN.code;
+ int errorCode =
+ (rootCause instanceof SolrException)
+ ? ((SolrException) rootCause).code()
+ : SolrException.ErrorCode.UNKNOWN.code;
boolean wasCommError =
- (rootCause instanceof ConnectException ||
- rootCause instanceof SocketException ||
- wasCommError(rootCause));
+ (rootCause instanceof ConnectException
+ || rootCause instanceof SocketException
+ || wasCommError(rootCause));
if (wasCommError
- || (exc instanceof RouteException && (errorCode == 503)) // 404 because the core does not exist 503 service unavailable
- //TODO there are other reasons for 404. We need to change the solr response format from HTML to structured data to know that
+ || (exc instanceof RouteException
+ && (errorCode == 503)) // 404 because the core does not exist 503 service unavailable
+ // TODO there are other reasons for 404. We need to change the solr response format from HTML
+ // to structured data to know that
) {
// it was a communication error. it is likely that
// the node to which the request to be sent is down . So , expire the state
@@ -950,32 +994,48 @@ public abstract class BaseCloudSolrClient extends SolrClient {
cacheEntry.maybeStale = true;
}
}
- if (retryCount < MAX_STALE_RETRIES) {//if it is a communication error , we must try again
- //may be, we have a stale version of the collection state
+ if (retryCount < MAX_STALE_RETRIES) { // if it is a communication error , we must try again
+ // may be, we have a stale version of the collection state
// and we could not get any information from the server
- //it is probably not worth trying again and again because
+ // it is probably not worth trying again and again because
// the state would not have been updated
- log.info("Request to collection {} failed due to ({}) {}, retry={} maxRetries={} commError={} errorCode={} - retrying",
- inputCollections, errorCode, rootCause, retryCount, MAX_STALE_RETRIES, wasCommError, errorCode);
+ log.info(
+ "Request to collection {} failed due to ({}) {}, retry={} maxRetries={} commError={} errorCode={} - retrying",
+ inputCollections,
+ errorCode,
+ rootCause,
+ retryCount,
+ MAX_STALE_RETRIES,
+ wasCommError,
+ errorCode);
return requestWithRetryOnStaleState(request, retryCount + 1, inputCollections);
}
} else {
log.info("request was not communication error it seems");
}
- log.info("Request to collection {} failed due to ({}) {}, retry={} maxRetries={} commError={} errorCode={} ",
- inputCollections, errorCode, rootCause, retryCount, MAX_STALE_RETRIES, wasCommError, errorCode);
+ log.info(
+ "Request to collection {} failed due to ({}) {}, retry={} maxRetries={} commError={} errorCode={} ",
+ inputCollections,
+ errorCode,
+ rootCause,
+ retryCount,
+ MAX_STALE_RETRIES,
+ wasCommError,
+ errorCode);
boolean stateWasStale = false;
- if (retryCount < MAX_STALE_RETRIES &&
- requestedCollections != null &&
- !requestedCollections.isEmpty() &&
- (SolrException.ErrorCode.getErrorCode(errorCode) == SolrException.ErrorCode.INVALID_STATE || errorCode == 404))
- {
+ if (retryCount < MAX_STALE_RETRIES
+ && requestedCollections != null
+ && !requestedCollections.isEmpty()
+ && (SolrException.ErrorCode.getErrorCode(errorCode)
+ == SolrException.ErrorCode.INVALID_STATE
+ || errorCode == 404)) {
// cached state for one or more external collections was stale
// re-issue request using updated state
stateWasStale = true;
- // just re-read state for all of them, which is a little heavy handed but hopefully a rare occurrence
+ // just re-read state for all of them, which is a little heavy handed but hopefully a rare
+ // occurrence
for (DocCollection ext : requestedCollections) {
collectionStateCache.remove(ext.getName());
}
@@ -983,18 +1043,19 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// if we experienced a communication error, it's worth checking the state
// with ZK just to make sure the node we're trying to hit is still part of the collection
- if (retryCount < MAX_STALE_RETRIES &&
- !stateWasStale &&
- requestedCollections != null &&
- !requestedCollections.isEmpty() &&
- wasCommError) {
+ if (retryCount < MAX_STALE_RETRIES
+ && !stateWasStale
+ && requestedCollections != null
+ && !requestedCollections.isEmpty()
+ && wasCommError) {
for (DocCollection ext : requestedCollections) {
DocCollection latestStateFromZk = getDocCollection(ext.getName(), null);
if (latestStateFromZk.getZNodeVersion() != ext.getZNodeVersion()) {
// looks like we couldn't reach the server because the state was stale == retry
stateWasStale = true;
// we just pulled state from ZK, so update the cache so that the retry uses it
- collectionStateCache.put(ext.getName(), new ExpiringCachedDocCollection(latestStateFromZk));
+ collectionStateCache.put(
+ ext.getName(), new ExpiringCachedDocCollection(latestStateFromZk));
}
}
}
@@ -1005,10 +1066,14 @@ public abstract class BaseCloudSolrClient extends SolrClient {
// if the state was stale, then we retry the request once with new state pulled from Zk
if (stateWasStale) {
- log.warn("Re-trying request to collection(s) {} after stale state error from server.", inputCollections);
- resp = requestWithRetryOnStaleState(request, retryCount+1, inputCollections);
+ log.warn(
+ "Re-trying request to collection(s) {} after stale state error from server.",
+ inputCollections);
+ resp = requestWithRetryOnStaleState(request, retryCount + 1, inputCollections);
} else {
- if (exc instanceof SolrException || exc instanceof SolrServerException || exc instanceof IOException) {
+ if (exc instanceof SolrException
+ || exc instanceof SolrServerException
+ || exc instanceof IOException) {
throw exc;
} else {
throw new SolrServerException(rootCause);
@@ -1030,10 +1095,16 @@ public abstract class BaseCloudSolrClient extends SolrClient {
if (request instanceof UpdateRequest) {
isUpdate = true;
if (inputCollections.size() > 1) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Update request must be sent to a single collection " +
- "or an alias: " + inputCollections);
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST,
+ "Update request must be sent to a single collection "
+ + "or an alias: "
+ + inputCollections);
}
- String collection = inputCollections.isEmpty() ? null : inputCollections.get(0); // getting first mimics HttpSolrCall
+ String collection =
+ inputCollections.isEmpty()
+ ? null
+ : inputCollections.get(0); // getting first mimics HttpSolrCall
NamedList<Object> response = directUpdate((AbstractUpdateRequest) request, collection);
if (response != null) {
return response;
@@ -1047,7 +1118,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
reqParams = new ModifiableSolrParams();
}
- ReplicaListTransformer replicaListTransformer = requestRLTGenerator.getReplicaListTransformer(reqParams);
+ ReplicaListTransformer replicaListTransformer =
+ requestRLTGenerator.getReplicaListTransformer(reqParams);
final ClusterStateProvider provider = getClusterStateProvider();
final String urlScheme = provider.getClusterProperty(ZkStateReader.URL_SCHEME, "http");
@@ -1070,22 +1142,26 @@ public abstract class BaseCloudSolrClient extends SolrClient {
} else { // Typical...
Set<String> collectionNames = resolveAliases(inputCollections, isUpdate);
if (collectionNames.isEmpty()) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
- "No collection param specified on request and no default collection has been set: " + inputCollections);
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST,
+ "No collection param specified on request and no default collection has been set: "
+ + inputCollections);
}
// TODO: not a big deal because of the caching, but we could avoid looking
// at every shard when getting leaders if we tweaked some things
- // Retrieve slices from the cloud state and, for each collection specified, add it to the Map of slices.
- Map<String,Slice> slices = new HashMap<>();
+ // Retrieve slices from the cloud state and, for each collection specified, add it to the Map
+ // of slices.
+ Map<String, Slice> slices = new HashMap<>();
String shardKeys = reqParams.get(ShardParams._ROUTE_);
for (String collectionName : collectionNames) {
DocCollection col = getDocCollection(collectionName, null);
if (col == null) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection not found: " + collectionName);
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST, "Collection not found: " + collectionName);
}
- Collection<Slice> routeSlices = col.getRouter().getSearchSlices(shardKeys, reqParams , col);
+ Collection<Slice> routeSlices = col.getRouter().getSearchSlices(shardKeys, reqParams, col);
ClientUtils.addSlices(slices, collectionName, routeSlices, true);
}
@@ -1097,8 +1173,9 @@ public abstract class BaseCloudSolrClient extends SolrClient {
for (Replica replica : slice.getReplicas()) {
String node = replica.getNodeName();
if (!liveNodes.contains(node) // Must be a live node to continue
- || replica.getState() != Replica.State.ACTIVE) // Must be an ACTIVE replica to continue
- continue;
+ || replica.getState()
+ != Replica.State.ACTIVE) // Must be an ACTIVE replica to continue
+ continue;
if (sendToLeaders && replica.equals(leader)) {
sortedReplicas.add(replica); // put leaders here eagerly (if sendToLeader mode)
} else {
@@ -1107,7 +1184,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
}
- // Sort the leader replicas, if any, according to the request preferences (none if !sendToLeaders)
+ // Sort the leader replicas, if any, according to the request preferences (none if
+ // !sendToLeaders)
replicaListTransformer.transform(sortedReplicas);
// Sort the replicas, if any, according to the request preferences and append to our list
@@ -1117,15 +1195,18 @@ public abstract class BaseCloudSolrClient extends SolrClient {
String joinedInputCollections = StrUtils.join(inputCollections, ',');
Set<String> seenNodes = new HashSet<>();
- sortedReplicas.forEach( replica -> {
- if (seenNodes.add(replica.getNodeName())) {
- theUrlList.add(ZkCoreNodeProps.getCoreUrl(replica.getBaseUrl(), joinedInputCollections));
- }
- });
+ sortedReplicas.forEach(
+ replica -> {
+ if (seenNodes.add(replica.getNodeName())) {
+ theUrlList.add(
+ ZkCoreNodeProps.getCoreUrl(replica.getBaseUrl(), joinedInputCollections));
+ }
+ });
if (theUrlList.isEmpty()) {
collectionStateCache.keySet().removeAll(collectionNames);
- throw new SolrException(SolrException.ErrorCode.INVALID_STATE,
+ throw new SolrException(
+ SolrException.ErrorCode.INVALID_STATE,
"Could not find a healthy node to handle the request.");
}
}
@@ -1135,7 +1216,10 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return rsp.getResponse();
}
- /** Resolves the input collections to their possible aliased collections. Doesn't validate collection existence. */
+ /**
+ * Resolves the input collections to their possible aliased collections. Doesn't validate
+ * collection existence.
+ */
private Set<String> resolveAliases(List<String> inputCollections, boolean isUpdate) {
if (inputCollections.isEmpty()) {
return Collections.emptySet();
@@ -1156,61 +1240,63 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return updatesToLeaders;
}
- /**
- * @return true if direct updates are sent to shard leaders only
- */
+ /** @return true if direct updates are sent to shard leaders only */
public boolean isDirectUpdatesToLeadersOnly() {
return directUpdatesToLeadersOnly;
}
- /**If caches are expired they are refreshed after acquiring a lock.
- * use this to set the number of locks
+ /**
+ * If caches are expired they are refreshed after acquiring a lock. use this to set the number of
+ * locks
*/
- public void setParallelCacheRefreshes(int n){ locks = objectList(n); }
+ public void setParallelCacheRefreshes(int n) {
+ locks = objectList(n);
+ }
protected static ArrayList<Object> objectList(int n) {
- ArrayList<Object> l = new ArrayList<>(n);
- for(int i=0;i<n;i++) l.add(new Object());
+ ArrayList<Object> l = new ArrayList<>(n);
+ for (int i = 0; i < n; i++) l.add(new Object());
return l;
}
-
- protected DocCollection getDocCollection(String collection, Integer expectedVersion) throws SolrException {
+ protected DocCollection getDocCollection(String collection, Integer expectedVersion)
+ throws SolrException {
if (expectedVersion == null) expectedVersion = -1;
if (collection == null) return null;
ExpiringCachedDocCollection cacheEntry = collectionStateCache.get(collection);
DocCollection col = cacheEntry == null ? null : cacheEntry.cached;
if (col != null) {
- if (expectedVersion <= col.getZNodeVersion()
- && !cacheEntry.shouldRetry()) return col;
+ if (expectedVersion <= col.getZNodeVersion() && !cacheEntry.shouldRetry()) return col;
}
ClusterState.CollectionRef ref = getCollectionRef(collection);
if (ref == null) {
- //no such collection exists
+ // no such collection exists
return null;
}
if (!ref.isLazilyLoaded()) {
- //it is readily available just return it
+ // it is readily available just return it
return ref.get();
}
List<Object> locks = this.locks;
- final Object lock = locks.get(Math.abs(Hash.murmurhash3_x86_32(collection, 0, collection.length(), 0) % locks.size()));
+ final Object lock =
+ locks.get(
+ Math.abs(
+ Hash.murmurhash3_x86_32(collection, 0, collection.length(), 0) % locks.size()));
DocCollection fetchedCol = null;
synchronized (lock) {
/*we have waited for sometime just check once again*/
cacheEntry = collectionStateCache.get(collection);
col = cacheEntry == null ? null : cacheEntry.cached;
if (col != null) {
- if (expectedVersion <= col.getZNodeVersion()
- && !cacheEntry.shouldRetry()) return col;
+ if (expectedVersion <= col.getZNodeVersion() && !cacheEntry.shouldRetry()) return col;
}
// We are going to fetch a new version
// we MUST try to get a new version
- fetchedCol = ref.get();//this is a call to ZK
- if (fetchedCol == null) return null;// this collection no more exists
+ fetchedCol = ref.get(); // this is a call to ZK
+ if (fetchedCol == null) return null; // this collection no more exists
if (col != null && fetchedCol.getZNodeVersion() == col.getZNodeVersion()) {
- cacheEntry.setRetriedAt();//we retried and found that it is the same version
+ cacheEntry.setRetriedAt(); // we retried and found that it is the same version
cacheEntry.maybeStale = false;
} else {
collectionStateCache.put(collection, new ExpiringCachedDocCollection(fetchedCol));
@@ -1224,19 +1310,17 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
/**
- * Useful for determining the minimum achieved replication factor across
- * all shards involved in processing an update request, typically useful
- * for gauging the replication factor of a batch.
+ * Useful for determining the minimum achieved replication factor across all shards involved in
+ * processing an update request, typically useful for gauging the replication factor of a batch.
*/
public int getMinAchievedReplicationFactor(String collection, NamedList<?> resp) {
// it's probably already on the top-level header set by condense
- NamedList<?> header = (NamedList<?>)resp.get("responseHeader");
- Integer achRf = (Integer)header.get(UpdateRequest.REPFACT);
- if (achRf != null)
- return achRf.intValue();
+ NamedList<?> header = (NamedList<?>) resp.get("responseHeader");
+ Integer achRf = (Integer) header.get(UpdateRequest.REPFACT);
+ if (achRf != null) return achRf.intValue();
// not on the top-level header, walk the shard route tree
- Map<String,Integer> shardRf = getShardReplicationFactor(collection, resp);
+ Map<String, Integer> shardRf = getShardReplicationFactor(collection, resp);
for (Integer rf : shardRf.values()) {
if (achRf == null || rf < achRf) {
achRf = rf;
@@ -1246,18 +1330,18 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
/**
- * Walks the NamedList response after performing an update request looking for
- * the replication factor that was achieved in each shard involved in the request.
- * For single doc updates, there will be only one shard in the return value.
+ * Walks the NamedList response after performing an update request looking for the replication
+ * factor that was achieved in each shard involved in the request. For single doc updates, there
+ * will be only one shard in the return value.
*/
- public Map<String,Integer> getShardReplicationFactor(String collection, NamedList<?> resp) {
+ public Map<String, Integer> getShardReplicationFactor(String collection, NamedList<?> resp) {
connect();
- Map<String,Integer> results = new HashMap<>();
+ Map<String, Integer> results = new HashMap<>();
if (resp instanceof RouteResponse) {
- NamedList<NamedList<?>> routes = ((RouteResponse<?>)resp).getRouteResponses();
+ NamedList<NamedList<?>> routes = ((RouteResponse<?>) resp).getRouteResponses();
DocCollection coll = getDocCollection(collection, null);
- Map<String,String> leaders = new HashMap<>();
+ Map<String, String> leaders = new HashMap<>();
for (Slice slice : coll.getActiveSlicesArr()) {
Replica leader = slice.getLeader();
if (leader != null) {
@@ -1269,17 +1353,17 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
}
- Iterator<Map.Entry<String,NamedList<?>>> routeIter = routes.iterator();
+ Iterator<Map.Entry<String, NamedList<?>>> routeIter = routes.iterator();
while (routeIter.hasNext()) {
- Map.Entry<String,NamedList<?>> next = routeIter.next();
+ Map.Entry<String, NamedList<?>> next = routeIter.next();
String host = next.getKey();
NamedList<?> hostResp = next.getValue();
- Integer rf = (Integer)((NamedList<?>)hostResp.get("responseHeader")).get(UpdateRequest.REPFACT);
+ Integer rf =
+ (Integer) ((NamedList<?>) hostResp.get("responseHeader")).get(UpdateRequest.REPFACT);
if (rf != null) {
String shard = leaders.get(host);
if (shard == null) {
- if (host.endsWith("/"))
- shard = leaders.get(host.substring(0,host.length()-1));
+ if (host.endsWith("/")) shard = leaders.get(host.substring(0, host.length() - 1));
if (shard == null) {
shard = host;
}
@@ -1292,8 +1376,8 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
private static boolean hasInfoToFindLeaders(UpdateRequest updateRequest, String idField) {
- final Map<SolrInputDocument,Map<String,Object>> documents = updateRequest.getDocumentsMap();
- final Map<String,Map<String,Object>> deleteById = updateRequest.getDeleteByIdMap();
+ final Map<SolrInputDocument, Map<String, Object>> documents = updateRequest.getDocumentsMap();
+ final Map<String, Map<String, Object>> deleteById = updateRequest.getDeleteByIdMap();
final boolean hasNoDocuments = (documents == null || documents.isEmpty());
final boolean hasNoDeleteById = (deleteById == null || deleteById.isEmpty());
@@ -1303,7 +1387,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
}
if (documents != null) {
- for (final Map.Entry<SolrInputDocument,Map<String,Object>> entry : documents.entrySet()) {
+ for (final Map.Entry<SolrInputDocument, Map<String, Object>> entry : documents.entrySet()) {
final SolrInputDocument doc = entry.getKey();
final Object fieldValue = doc.getFieldValue(idField);
if (fieldValue == null) {
@@ -1315,5 +1399,4 @@ public abstract class BaseCloudSolrClient extends SolrClient {
return true;
}
-
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
index 22c133f..5722822 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpClusterStateProvider.java
@@ -17,6 +17,8 @@
package org.apache.solr.client.solrj.impl;
+import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.*;
+
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Collections;
@@ -26,7 +28,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
-
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@@ -42,8 +43,6 @@ import org.apache.solr.common.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.*;
-
public abstract class BaseHttpClusterStateProvider implements ClusterStateProvider {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -57,8 +56,8 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
private int cacheTimeout = 5; // the liveNodes and aliases cache will be invalidated after 5 secs
public void init(List<String> solrUrls) throws Exception {
- for (String solrUrl: solrUrls) {
- urlScheme = solrUrl.startsWith("https")? "https": "http";
+ for (String solrUrl : solrUrls) {
+ urlScheme = solrUrl.startsWith("https") ? "https" : "http";
try (SolrClient initialClient = getSolrClient(solrUrl)) {
this.liveNodes = fetchLiveNodes(initialClient);
liveNodesTimestamp = System.nanoTime();
@@ -69,11 +68,14 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
}
if (this.liveNodes == null || this.liveNodes.isEmpty()) {
- throw new RuntimeException("Tried fetching live_nodes using Solr URLs provided, i.e. " + solrUrls + ". However, "
- + "succeeded in obtaining the cluster state from none of them."
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using working"
- + " solrUrl(s) or zkHost(s).");
+ throw new RuntimeException(
+ "Tried fetching live_nodes using Solr URLs provided, i.e. "
+ + solrUrls
+ + ". However, "
+ + "succeeded in obtaining the cluster state from none of them."
+ + "If you think your Solr cluster is up and is accessible,"
+ + " you could try re-creating a new CloudSolrClient using working"
+ + " solrUrl(s) or zkHost(s).");
}
}
@@ -81,14 +83,16 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
@Override
public ClusterState.CollectionRef getState(String collection) {
- for (String nodeName: liveNodes) {
+ for (String nodeName : liveNodes) {
String baseUrl = Utils.getBaseUrlForNodeName(nodeName, urlScheme);
try (SolrClient client = getSolrClient(baseUrl)) {
ClusterState cs = fetchClusterState(client, collection, null);
return cs.getCollectionRef(collection);
} catch (SolrServerException | IOException e) {
- log.warn("Attempt to fetch cluster state from {} failed."
- , Utils.getBaseUrlForNodeName(nodeName, urlScheme), e);
+ log.warn(
+ "Attempt to fetch cluster state from {} failed.",
+ Utils.getBaseUrlForNodeName(nodeName, urlScheme),
+ e);
} catch (RemoteSolrException e) {
if ("NOT_FOUND".equals(e.getMetadata("CLUSTERSTATUS"))) {
return null;
@@ -101,15 +105,20 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
return null;
}
}
- throw new RuntimeException("Tried fetching cluster state using the node names we knew of, i.e. " + liveNodes +". However, "
- + "succeeded in obtaining the cluster state from none of them."
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using working"
- + " solrUrl(s) or zkHost(s).");
+ throw new RuntimeException(
+ "Tried fetching cluster state using the node names we knew of, i.e. "
+ + liveNodes
+ + ". However, "
+ + "succeeded in obtaining the cluster state from none of them."
+ + "If you think your Solr cluster is up and is accessible,"
+ + " you could try re-creating a new CloudSolrClient using working"
+ + " solrUrl(s) or zkHost(s).");
}
@SuppressWarnings("unchecked")
- private ClusterState fetchClusterState(SolrClient client, String collection, Map<String, Object> clusterProperties) throws SolrServerException, IOException, NotACollectionException {
+ private ClusterState fetchClusterState(
+ SolrClient client, String collection, Map<String, Object> clusterProperties)
+ throws SolrServerException, IOException, NotACollectionException {
ModifiableSolrParams params = new ModifiableSolrParams();
if (collection != null) {
params.set("collection", collection);
@@ -120,10 +129,11 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
SimpleOrderedMap<?> cluster = (SimpleOrderedMap<?>) client.request(request).get("cluster");
Map<String, Object> collectionsMap;
if (collection != null) {
- collectionsMap = Collections.singletonMap(collection,
- ((NamedList<?>) cluster.get("collections")).get(collection));
+ collectionsMap =
+ Collections.singletonMap(
+ collection, ((NamedList<?>) cluster.get("collections")).get(collection));
} else {
- collectionsMap = ((NamedList<?>)cluster.get("collections")).asMap(10);
+ collectionsMap = ((NamedList<?>) cluster.get("collections")).asMap(10);
}
int znodeVersion;
Map<String, Object> collFromStatus = (Map<String, Object>) (collectionsMap).get(collection);
@@ -131,11 +141,11 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
throw new NotACollectionException(); // probably an alias
}
if (collection != null) { // can be null if alias
- znodeVersion = (int) collFromStatus.get("znodeVersion");
+ znodeVersion = (int) collFromStatus.get("znodeVersion");
} else {
znodeVersion = -1;
}
- Set<String> liveNodes = new HashSet<>((List<String>)(cluster.get("live_nodes")));
+ Set<String> liveNodes = new HashSet<>((List<String>) (cluster.get("live_nodes")));
this.liveNodes = liveNodes;
liveNodesTimestamp = System.nanoTime();
ClusterState cs = ClusterState.createFromCollectionMap(znodeVersion, collectionsMap, liveNodes);
@@ -151,14 +161,16 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
@Override
public Set<String> getLiveNodes() {
if (liveNodes == null) {
- throw new RuntimeException("We don't know of any live_nodes to fetch the"
- + " latest live_nodes information from. "
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using working"
- + " solrUrl(s) or zkHost(s).");
+ throw new RuntimeException(
+ "We don't know of any live_nodes to fetch the"
+ + " latest live_nodes information from. "
+ + "If you think your Solr cluster is up and is accessible,"
+ + " you could try re-creating a new CloudSolrClient using working"
+ + " solrUrl(s) or zkHost(s).");
}
- if (TimeUnit.SECONDS.convert((System.nanoTime() - liveNodesTimestamp), TimeUnit.NANOSECONDS) > getCacheTimeout()) {
- for (String nodeName: liveNodes) {
+ if (TimeUnit.SECONDS.convert((System.nanoTime() - liveNodesTimestamp), TimeUnit.NANOSECONDS)
+ > getCacheTimeout()) {
+ for (String nodeName : liveNodes) {
String baseUrl = Utils.getBaseUrlForNodeName(nodeName, urlScheme);
try (SolrClient client = getSolrClient(baseUrl)) {
Set<String> liveNodes = fetchLiveNodes(client);
@@ -169,11 +181,14 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
log.warn("Attempt to fetch cluster state from {} failed.", baseUrl, e);
}
}
- throw new RuntimeException("Tried fetching live_nodes using all the node names we knew of, i.e. " + liveNodes +". However, "
- + "succeeded in obtaining the cluster state from none of them."
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using working"
- + " solrUrl(s) or zkHost(s).");
+ throw new RuntimeException(
+ "Tried fetching live_nodes using all the node names we knew of, i.e. "
+ + liveNodes
+ + ". However, "
+ + "succeeded in obtaining the cluster state from none of them."
+ + "If you think your Solr cluster is up and is accessible,"
+ + " you could try re-creating a new CloudSolrClient using working"
+ + " solrUrl(s) or zkHost(s).");
} else {
return liveNodes; // cached copy is fresh enough
}
@@ -186,7 +201,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
NamedList cluster = (SimpleOrderedMap) client.request(request).get("cluster");
- return (Set<String>) new HashSet((List<String>)(cluster.get("live_nodes")));
+ return (Set<String>) new HashSet((List<String>) (cluster.get("live_nodes")));
}
@Override
@@ -205,30 +220,35 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
private Map<String, List<String>> getAliases(boolean forceFetch) {
if (this.liveNodes == null) {
- throw new RuntimeException("We don't know of any live_nodes to fetch the"
- + " latest aliases information from. "
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using working"
- + " solrUrl(s) or zkHost(s).");
+ throw new RuntimeException(
+ "We don't know of any live_nodes to fetch the"
+ + " latest aliases information from. "
+ + "If you think your Solr cluster is up and is accessible,"
+ + " you could try re-creating a new CloudSolrClient using working"
+ + " solrUrl(s) or zkHost(s).");
}
- if (forceFetch || this.aliases == null ||
- TimeUnit.SECONDS.convert((System.nanoTime() - aliasesTimestamp), TimeUnit.NANOSECONDS) > getCacheTimeout()) {
- for (String nodeName: liveNodes) {
+ if (forceFetch
+ || this.aliases == null
+ || TimeUnit.SECONDS.convert((System.nanoTime() - aliasesTimestamp), TimeUnit.NANOSECONDS)
+ > getCacheTimeout()) {
+ for (String nodeName : liveNodes) {
String baseUrl = Utils.getBaseUrlForNodeName(nodeName, urlScheme);
try (SolrClient client = getSolrClient(baseUrl)) {
- CollectionAdminResponse response = new CollectionAdminRequest.ListAliases().process(client);
+ CollectionAdminResponse response =
+ new CollectionAdminRequest.ListAliases().process(client);
this.aliases = response.getAliasesAsLists();
this.aliasProperties = response.getAliasProperties(); // side-effect
this.aliasesTimestamp = System.nanoTime();
return Collections.unmodifiableMap(this.aliases);
} catch (SolrServerException | RemoteSolrException | IOException e) {
// Situation where we're hitting an older Solr which doesn't have LISTALIASES
- if (e instanceof RemoteSolrException && ((RemoteSolrException)e).code()==400) {
- log.warn("LISTALIASES not found, possibly using older Solr server. Aliases won't work {}"
- ,"unless you re-create the CloudSolrClient using zkHost(s) or upgrade Solr server"
- , e);
+ if (e instanceof RemoteSolrException && ((RemoteSolrException) e).code() == 400) {
+ log.warn(
+ "LISTALIASES not found, possibly using older Solr server. Aliases won't work {}",
+ "unless you re-create the CloudSolrClient using zkHost(s) or upgrade Solr server",
+ e);
this.aliases = Collections.emptyMap();
this.aliasProperties = Collections.emptyMap();
this.aliasesTimestamp = System.nanoTime();
@@ -238,11 +258,14 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
}
}
- throw new RuntimeException("Tried fetching aliases using all the node names we knew of, i.e. " + liveNodes +". However, "
- + "succeeded in obtaining the cluster state from none of them."
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using a working"
- + " solrUrl or zkHost.");
+ throw new RuntimeException(
+ "Tried fetching aliases using all the node names we knew of, i.e. "
+ + liveNodes
+ + ". However, "
+ + "succeeded in obtaining the cluster state from none of them."
+ + "If you think your Solr cluster is up and is accessible,"
+ + " you could try re-creating a new CloudSolrClient using a working"
+ + " solrUrl or zkHost.");
} else {
return Collections.unmodifiableMap(this.aliases); // cached copy is fresh enough
}
@@ -256,7 +279,7 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
@Override
public ClusterState getClusterState() throws IOException {
- for (String nodeName: liveNodes) {
+ for (String nodeName : liveNodes) {
String baseUrl = Utils.getBaseUrlForNodeName(nodeName, urlScheme);
try (SolrClient client = getSolrClient(baseUrl)) {
return fetchClusterState(client, null, null);
@@ -264,15 +287,19 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
log.warn("Attempt to fetch cluster state from {} failed.", baseUrl, e);
} catch (NotACollectionException e) {
// not possible! (we passed in null for collection so it can't be an alias)
- throw new RuntimeException("null should never cause NotACollectionException in " +
- "fetchClusterState() Please report this as a bug!");
+ throw new RuntimeException(
+ "null should never cause NotACollectionException in "
+ + "fetchClusterState() Please report this as a bug!");
}
}
- throw new RuntimeException("Tried fetching cluster state using the node names we knew of, i.e. " + liveNodes +". However, "
- + "succeeded in obtaining the cluster state from none of them."
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using working"
- + " solrUrl(s) or zkHost(s).");
+ throw new RuntimeException(
+ "Tried fetching cluster state using the node names we knew of, i.e. "
+ + liveNodes
+ + ". However, "
+ + "succeeded in obtaining the cluster state from none of them."
+ + "If you think your Solr cluster is up and is accessible,"
+ + " you could try re-creating a new CloudSolrClient using working"
+ + " solrUrl(s) or zkHost(s).");
}
@Override
@@ -287,22 +314,27 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
log.warn("Attempt to fetch cluster state from {} failed.", baseUrl, e);
} catch (NotACollectionException e) {
// not possible! (we passed in null for collection so it can't be an alias)
- throw new RuntimeException("null should never cause NotACollectionException in " +
- "fetchClusterState() Please report this as a bug!");
+ throw new RuntimeException(
+ "null should never cause NotACollectionException in "
+ + "fetchClusterState() Please report this as a bug!");
}
}
- throw new RuntimeException("Tried fetching cluster state using the node names we knew of, i.e. " + liveNodes + ". However, "
- + "succeeded in obtaining the cluster state from none of them."
- + "If you think your Solr cluster is up and is accessible,"
- + " you could try re-creating a new CloudSolrClient using working"
- + " solrUrl(s) or zkHost(s).");
+ throw new RuntimeException(
+ "Tried fetching cluster state using the node names we knew of, i.e. "
+ + liveNodes
+ + ". However, "
+ + "succeeded in obtaining the cluster state from none of them."
+ + "If you think your Solr cluster is up and is accessible,"
+ + " you could try re-creating a new CloudSolrClient using working"
+ + " solrUrl(s) or zkHost(s).");
}
@Override
public String getPolicyNameByCollection(String coll) {
- throw new UnsupportedOperationException("Fetching cluster properties not supported"
- + " using the HttpClusterStateProvider. "
- + "ZkClientClusterStateProvider can be used for this."); // TODO
+ throw new UnsupportedOperationException(
+ "Fetching cluster properties not supported"
+ + " using the HttpClusterStateProvider. "
+ + "ZkClientClusterStateProvider can be used for this."); // TODO
}
@Override
@@ -325,6 +357,5 @@ public abstract class BaseHttpClusterStateProvider implements ClusterStateProvid
}
// This exception is not meant to escape this class it should be caught and wrapped.
- private class NotACollectionException extends Exception {
- }
+ private class NotACollectionException extends Exception {}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java
index 8dcf3d9..2781adb 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseHttpSolrClient.java
@@ -17,20 +17,18 @@
package org.apache.solr.client.solrj.impl;
-import java.util.Collections;
+import static org.apache.solr.common.util.Utils.getObjectByPath;
+import java.util.Collections;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.util.NamedList;
-import static org.apache.solr.common.util.Utils.getObjectByPath;
-
public abstract class BaseHttpSolrClient extends SolrClient {
/**
- * Subclass of SolrException that allows us to capture an arbitrary HTTP
- * status code that may have been returned by the remote server or a
- * proxy along the way.
+ * Subclass of SolrException that allows us to capture an arbitrary HTTP status code that may have
+ * been returned by the remote server or a proxy along the way.
*/
public static class RemoteSolrException extends SolrException {
/**
@@ -45,8 +43,8 @@ public abstract class BaseHttpSolrClient extends SolrClient {
}
/**
- * This should be thrown when a server has an error in executing the request and
- * it sends a proper payload back to the client
+ * This should be thrown when a server has an error in executing the request and it sends a proper
+ * payload back to the client
*/
public static class RemoteExecutionException extends RemoteSolrException {
private NamedList<?> meta;
@@ -56,24 +54,24 @@ public abstract class BaseHttpSolrClient extends SolrClient {
this.meta = meta;
}
-
public static RemoteExecutionException create(String host, NamedList<?> errResponse) {
Object errObj = errResponse.get("error");
if (errObj != null) {
Number code = (Number) getObjectByPath(errObj, true, Collections.singletonList("code"));
String msg = (String) getObjectByPath(errObj, true, Collections.singletonList("msg"));
- return new RemoteExecutionException(host, code == null ? ErrorCode.UNKNOWN.code : code.intValue(),
- msg == null ? "Unknown Error" : msg, errResponse);
+ return new RemoteExecutionException(
+ host,
+ code == null ? ErrorCode.UNKNOWN.code : code.intValue(),
+ msg == null ? "Unknown Error" : msg,
+ errResponse);
} else {
throw new RuntimeException("No error");
}
-
}
public NamedList<?> getMetaData() {
return meta;
}
}
-
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java
index 1fcd72e..b489f88 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryRequestWriter.java
@@ -16,23 +16,21 @@
*/
package org.apache.solr.client.solrj.impl;
+import static org.apache.solr.common.params.CommonParams.JAVABIN_MIME;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
-
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec;
import org.apache.solr.client.solrj.request.RequestWriter;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.util.ContentStream;
-import static org.apache.solr.common.params.CommonParams.JAVABIN_MIME;
-
/**
* A RequestWriter which writes requests in the javabin format
*
- *
* @see org.apache.solr.client.solrj.request.RequestWriter
* @since solr 1.4
*/
@@ -63,14 +61,13 @@ public class BinaryRequestWriter extends RequestWriter {
public Collection<ContentStream> getContentStreams(SolrRequest<?> req) throws IOException {
if (req instanceof UpdateRequest) {
UpdateRequest updateRequest = (UpdateRequest) req;
- if (isEmpty(updateRequest) ) return null;
+ if (isEmpty(updateRequest)) return null;
throw new RuntimeException("This Should not happen");
} else {
return super.getContentStreams(req);
}
}
-
@Override
public String getUpdateContentType() {
return JAVABIN_MIME;
@@ -83,7 +80,7 @@ public class BinaryRequestWriter extends RequestWriter {
new JavaBinUpdateRequestCodec().marshal(updateRequest, os);
}
}
-
+
/*
* A hack to get access to the protected internal buffer and avoid an additional copy
*/
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryResponseParser.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryResponseParser.java
index b146dcd..ec604fa 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryResponseParser.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BinaryResponseParser.java
@@ -16,19 +16,15 @@
*/
package org.apache.solr.client.solrj.impl;
-import org.apache.solr.client.solrj.ResponseParser;
-import org.apache.solr.common.SolrException;
-import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.JavaBinCodec;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
+import org.apache.solr.client.solrj.ResponseParser;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.JavaBinCodec;
+import org.apache.solr.common.util.NamedList;
-/**
- *
- * @since solr 1.3
- */
+/** @since solr 1.3 */
public class BinaryResponseParser extends ResponseParser {
public static final String BINARY_CONTENT_TYPE = "application/octet-stream";
@@ -51,7 +47,6 @@ public class BinaryResponseParser extends ResponseParser {
return (NamedList<Object>) createCodec().unmarshal(body);
} catch (IOException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "parsing error", e);
-
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
index 7214956..34c3315 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
@@ -22,21 +22,19 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
-
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrException;
/**
- * SolrJ client class to communicate with SolrCloud using Http2SolrClient.
- * Instances of this class communicate with Zookeeper to discover
- * Solr endpoints for SolrCloud collections, and then use the
+ * SolrJ client class to communicate with SolrCloud using Http2SolrClient. Instances of this class
+ * communicate with Zookeeper to discover Solr endpoints for SolrCloud collections, and then use the
* {@link LBHttp2SolrClient} to issue requests.
*
* @lucene.experimental
* @since solr 8.0
*/
@SuppressWarnings("serial")
-public class CloudHttp2SolrClient extends BaseCloudSolrClient {
+public class CloudHttp2SolrClient extends BaseCloudSolrClient {
private final ClusterStateProvider stateProvider;
private final LBHttp2SolrClient lbClient;
@@ -44,10 +42,10 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
private final boolean clientIsInternal;
/**
- * Create a new client object that connects to Zookeeper and is always aware
- * of the SolrCloud state. If there is a fully redundant Zookeeper quorum and
- * SolrCloud has enough replicas for every shard in a collection, there is no
- * single point of failure. Updates will be sent to shard leaders by default.
+ * Create a new client object that connects to Zookeeper and is always aware of the SolrCloud
+ * state. If there is a fully redundant Zookeeper quorum and SolrCloud has enough replicas for
+ * every shard in a collection, there is no single point of failure. Updates will be sent to shard
+ * leaders by default.
*
* @param builder a {@link Http2SolrClient.Builder} with the options used to create the client.
*/
@@ -66,7 +64,8 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
}
if (builder.stateProvider == null) {
if (builder.zkHosts != null && builder.solrUrls != null) {
- throw new IllegalArgumentException("Both zkHost(s) & solrUrl(s) have been specified. Only specify one.");
+ throw new IllegalArgumentException(
+ "Both zkHost(s) & solrUrl(s) have been specified. Only specify one.");
}
if (builder.zkHosts != null) {
this.stateProvider = new ZkClientClusterStateProvider(builder.zkHosts, builder.zkChroot);
@@ -74,8 +73,12 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
try {
this.stateProvider = new Http2ClusterStateProvider(builder.solrUrls, builder.httpClient);
} catch (Exception e) {
- throw new RuntimeException("Couldn't initialize a HttpClusterStateProvider (is/are the "
- + "Solr server(s), " + builder.solrUrls + ", down?)", e);
+ throw new RuntimeException(
+ "Couldn't initialize a HttpClusterStateProvider (is/are the "
+ + "Solr server(s), "
+ + builder.solrUrls
+ + ", down?)",
+ e);
}
} else {
throw new IllegalArgumentException("Both zkHosts and solrUrl cannot be null.");
@@ -84,16 +87,14 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
this.stateProvider = builder.stateProvider;
}
this.lbClient = new LBHttp2SolrClient(myClient);
-
}
-
@Override
public void close() throws IOException {
stateProvider.close();
lbClient.close();
- if (clientIsInternal && myClient!=null) {
+ if (clientIsInternal && myClient != null) {
myClient.close();
}
@@ -118,9 +119,7 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
return false;
}
- /**
- * Constructs {@link CloudHttp2SolrClient} instances from provided configuration.
- */
+ /** Constructs {@link CloudHttp2SolrClient} instances from provided configuration. */
public static class Builder {
protected Collection<String> zkHosts = new ArrayList<>();
protected List<String> solrUrls = new ArrayList<>();
@@ -133,13 +132,15 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
protected Http2SolrClient.Builder internalClientBuilder;
/**
- * Provide a series of Solr URLs to be used when configuring {@link CloudHttp2SolrClient} instances.
- * The solr client will use these urls to understand the cluster topology, which solr nodes are active etc.
+ * Provide a series of Solr URLs to be used when configuring {@link CloudHttp2SolrClient}
+ * instances. The solr client will use these urls to understand the cluster topology, which solr
+ * nodes are active etc.
*
- * Provided Solr URLs are expected to point to the root Solr path ("http://hostname:8983/solr"); they should not
- * include any collections, cores, or other path components.
+ * <p>Provided Solr URLs are expected to point to the root Solr path
+ * ("http://hostname:8983/solr"); they should not include any collections, cores, or other path
+ * components.
*
- * Usage example:
+ * <p>Usage example:
*
* <pre>
* final List<String> solrBaseUrls = new ArrayList<String>();
@@ -152,9 +153,10 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
}
/**
- * Provide a series of ZK hosts which will be used when configuring {@link CloudHttp2SolrClient} instances.
+ * Provide a series of ZK hosts which will be used when configuring {@link CloudHttp2SolrClient}
+ * instances.
*
- * Usage example when Solr stores data at the ZooKeeper root ('/'):
+ * <p>Usage example when Solr stores data at the ZooKeeper root ('/'):
*
* <pre>
* final List<String> zkServers = new ArrayList<String>();
@@ -164,14 +166,15 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
*
* Usage example when Solr data is stored in a ZooKeeper chroot:
*
- * <pre>
+ * <pre>
* final List<String> zkServers = new ArrayList<String>();
* zkServers.add("zookeeper1:2181"); zkServers.add("zookeeper2:2181"); zkServers.add("zookeeper3:2181");
* final SolrClient client = new CloudHttp2SolrClient.Builder(zkServers, Optional.of("/solr")).build();
* </pre>
*
* @param zkHosts a List of at least one ZooKeeper host and port (e.g. "zookeeper1:2181")
- * @param zkChroot the path to the root ZooKeeper node containing Solr data. Provide {@code java.util.Optional.empty()} if no ZK chroot is used.
+ * @param zkChroot the path to the root ZooKeeper node containing Solr data. Provide {@code
+ * java.util.Optional.empty()} if no ZK chroot is used.
*/
public Builder(List<String> zkHosts, Optional<String> zkChroot) {
this.zkHosts = zkHosts;
@@ -179,9 +182,11 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
}
/**
- * Tells {@link CloudHttp2SolrClient.Builder} that created clients should send direct updates to shard leaders only.
+ * Tells {@link CloudHttp2SolrClient.Builder} that created clients should send direct updates to
+ * shard leaders only.
*
- * UpdateRequests whose leaders cannot be found will "fail fast" on the client side with a {@link SolrException}
+ * <p>UpdateRequests whose leaders cannot be found will "fail fast" on the client side with a
+ * {@link SolrException}
*/
public Builder sendDirectUpdatesToShardLeadersOnly() {
directUpdatesToLeadersOnly = true;
@@ -189,10 +194,11 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
}
/**
- * Tells {@link CloudHttp2SolrClient.Builder} that created clients can send updates to any shard replica (shard leaders and non-leaders).
+ * Tells {@link CloudHttp2SolrClient.Builder} that created clients can send updates to any shard
+ * replica (shard leaders and non-leaders).
*
- * Shard leaders are still preferred, but the created clients will fallback to using other replicas if a leader
- * cannot be found.
+ * <p>Shard leaders are still preferred, but the created clients will fallback to using other
+ * replicas if a leader cannot be found.
*/
public Builder sendDirectUpdatesToAnyShardReplica() {
directUpdatesToLeadersOnly = false;
@@ -200,12 +206,14 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
}
/**
- * Tells {@link CloudHttp2SolrClient.Builder} whether created clients should send shard updates serially or in parallel
+ * Tells {@link CloudHttp2SolrClient.Builder} whether created clients should send shard updates
+ * serially or in parallel
*
- * When an {@link UpdateRequest} affects multiple shards, {@link CloudHttp2SolrClient} splits it up and sends a request
- * to each affected shard. This setting chooses whether those sub-requests are sent serially or in parallel.
- * <p>
- * If not set, this defaults to 'true' and sends sub-requests in parallel.
+ * <p>When an {@link UpdateRequest} affects multiple shards, {@link CloudHttp2SolrClient} splits
+ * it up and sends a request to each affected shard. This setting chooses whether those
+ * sub-requests are sent serially or in parallel.
+ *
+ * <p>If not set, this defaults to 'true' and sends sub-requests in parallel.
*/
public Builder withParallelUpdates(boolean parallelUpdates) {
this.parallelUpdates = parallelUpdates;
@@ -214,41 +222,45 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
public Builder withHttpClient(Http2SolrClient httpClient) {
if (this.internalClientBuilder != null) {
- throw new IllegalStateException("The builder can't accept an httpClient AND an internalClientBuilder, only one of those can be provided");
+ throw new IllegalStateException(
+ "The builder can't accept an httpClient AND an internalClientBuilder, only one of those can be provided");
}
this.httpClient = httpClient;
return this;
}
/**
- * If provided, the CloudHttp2SolrClient will build it's internal Http2SolrClient using this builder
- * (instead of the empty default one). Providing this builder allows users to configure the internal
- * clients (authentication, timeouts, etc).
+ * If provided, the CloudHttp2SolrClient will build it's internal Http2SolrClient using this
+ * builder (instead of the empty default one). Providing this builder allows users to configure
+ * the internal clients (authentication, timeouts, etc).
+ *
* @param internalClientBuilder the builder to use for creating the internal http client.
* @return this
*/
public Builder withInternalClientBuilder(Http2SolrClient.Builder internalClientBuilder) {
if (this.httpClient != null) {
- throw new IllegalStateException("The builder can't accept an httpClient AND an internalClientBuilder, only one of those can be provided");
+ throw new IllegalStateException(
+ "The builder can't accept an httpClient AND an internalClientBuilder, only one of those can be provided");
}
this.internalClientBuilder = internalClientBuilder;
return this;
}
- /**
- * Create a {@link CloudHttp2SolrClient} based on the provided configuration.
- */
+ /** Create a {@link CloudHttp2SolrClient} based on the provided configuration. */
public CloudHttp2SolrClient build() {
if (stateProvider == null) {
if (!zkHosts.isEmpty()) {
stateProvider = new ZkClientClusterStateProvider(zkHosts, zkChroot);
- }
- else if (!this.solrUrls.isEmpty()) {
+ } else if (!this.solrUrls.isEmpty()) {
try {
stateProvider = new Http2ClusterStateProvider(solrUrls, httpClient);
} catch (Exception e) {
- throw new RuntimeException("Couldn't initialize a HttpClusterStateProvider (is/are the "
- + "Solr server(s), " + solrUrls + ", down?)", e);
+ throw new RuntimeException(
+ "Couldn't initialize a HttpClusterStateProvider (is/are the "
+ + "Solr server(s), "
+ + solrUrls
+ + ", down?)",
+ e);
}
} else {
throw new IllegalArgumentException("Both zkHosts and solrUrl cannot be null.");
@@ -256,6 +268,5 @@ public class CloudHttp2SolrClient extends BaseCloudSolrClient {
}
return new CloudHttp2SolrClient(this);
}
-
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index ab51b8d..98ebb90 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ConnectTimeoutException;
@@ -34,10 +33,9 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
/**
- * SolrJ client class to communicate with SolrCloud.
- * Instances of this class communicate with Zookeeper to discover
- * Solr endpoints for SolrCloud collections, and then use the
- * {@link LBHttpSolrClient} to issue requests.
+ * SolrJ client class to communicate with SolrCloud. Instances of this class communicate with
+ * Zookeeper to discover Solr endpoints for SolrCloud collections, and then use the {@link
+ * LBHttpSolrClient} to issue requests.
*/
public class CloudSolrClient extends BaseCloudSolrClient {
@@ -50,10 +48,10 @@ public class CloudSolrClient extends BaseCloudSolrClient {
public static final String STATE_VERSION = BaseCloudSolrClient.STATE_VERSION;
/**
- * Create a new client object that connects to Zookeeper and is always aware
- * of the SolrCloud state. If there is a fully redundant Zookeeper quorum and
- * SolrCloud has enough replicas for every shard in a collection, there is no
- * single point of failure. Updates will be sent to shard leaders by default.
+ * Create a new client object that connects to Zookeeper and is always aware of the SolrCloud
+ * state. If there is a fully redundant Zookeeper quorum and SolrCloud has enough replicas for
+ * every shard in a collection, there is no single point of failure. Updates will be sent to shard
+ * leaders by default.
*
* @param builder a {@link CloudSolrClient.Builder} with the options used to create the client.
*/
@@ -61,7 +59,8 @@ public class CloudSolrClient extends BaseCloudSolrClient {
super(builder.shardLeadersOnly, builder.parallelUpdates, builder.directUpdatesToLeadersOnly);
if (builder.stateProvider == null) {
if (builder.zkHosts != null && builder.solrUrls != null) {
- throw new IllegalArgumentException("Both zkHost(s) & solrUrl(s) have been specified. Only specify one.");
+ throw new IllegalArgumentException(
+ "Both zkHost(s) & solrUrl(s) have been specified. Only specify one.");
}
if (builder.zkHosts != null) {
this.stateProvider = new ZkClientClusterStateProvider(builder.zkHosts, builder.zkChroot);
@@ -69,8 +68,12 @@ public class CloudSolrClient extends BaseCloudSolrClient {
try {
this.stateProvider = new HttpClusterStateProvider(builder.solrUrls, builder.httpClient);
} catch (Exception e) {
- throw new RuntimeException("Couldn't initialize a HttpClusterStateProvider (is/are the "
- + "Solr server(s), " + builder.solrUrls + ", down?)", e);
+ throw new RuntimeException(
+ "Couldn't initialize a HttpClusterStateProvider (is/are the "
+ + "Solr server(s), "
+ + builder.solrUrls
+ + ", down?)",
+ e);
}
} else {
throw new IllegalArgumentException("Both zkHosts and solrUrl cannot be null.");
@@ -80,47 +83,59 @@ public class CloudSolrClient extends BaseCloudSolrClient {
}
this.clientIsInternal = builder.httpClient == null;
this.shutdownLBHttpSolrServer = builder.loadBalancedSolrClient == null;
- if(builder.lbClientBuilder != null) {
+ if (builder.lbClientBuilder != null) {
propagateLBClientConfigOptions(builder);
builder.loadBalancedSolrClient = builder.lbClientBuilder.build();
}
- if(builder.loadBalancedSolrClient != null) builder.httpClient = builder.loadBalancedSolrClient.getHttpClient();
- this.myClient = (builder.httpClient == null) ? HttpClientUtil.createClient(null) : builder.httpClient;
- if (builder.loadBalancedSolrClient == null) builder.loadBalancedSolrClient = createLBHttpSolrClient(builder, myClient);
+ if (builder.loadBalancedSolrClient != null)
+ builder.httpClient = builder.loadBalancedSolrClient.getHttpClient();
+ this.myClient =
+ (builder.httpClient == null) ? HttpClientUtil.createClient(null) : builder.httpClient;
+ if (builder.loadBalancedSolrClient == null)
+ builder.loadBalancedSolrClient = createLBHttpSolrClient(builder, myClient);
this.lbClient = builder.loadBalancedSolrClient;
}
-
+
private void propagateLBClientConfigOptions(Builder builder) {
final LBHttpSolrClient.Builder lbBuilder = builder.lbClientBuilder;
-
+
if (builder.connectionTimeoutMillis != null) {
lbBuilder.withConnectionTimeout(builder.connectionTimeoutMillis);
}
-
+
if (builder.socketTimeoutMillis != null) {
lbBuilder.withSocketTimeout(builder.socketTimeoutMillis);
}
}
- protected Map<String, LBSolrClient.Req> createRoutes(UpdateRequest updateRequest, ModifiableSolrParams routableParams,
- DocCollection col, DocRouter router, Map<String, List<String>> urlMap,
- String idField) {
- return urlMap == null ? null : updateRequest.getRoutesToCollection(router, col, urlMap, routableParams, idField);
+ protected Map<String, LBSolrClient.Req> createRoutes(
+ UpdateRequest updateRequest,
+ ModifiableSolrParams routableParams,
+ DocCollection col,
+ DocRouter router,
+ Map<String, List<String>> urlMap,
+ String idField) {
+ return urlMap == null
+ ? null
+ : updateRequest.getRoutesToCollection(router, col, urlMap, routableParams, idField);
}
- protected RouteException getRouteException(SolrException.ErrorCode serverError, NamedList<Throwable> exceptions, Map<String, ? extends LBSolrClient.Req> routes) {
+ protected RouteException getRouteException(
+ SolrException.ErrorCode serverError,
+ NamedList<Throwable> exceptions,
+ Map<String, ? extends LBSolrClient.Req> routes) {
return new RouteException(serverError, exceptions, routes);
}
@Override
public void close() throws IOException {
stateProvider.close();
-
+
if (shutdownLBHttpSolrServer) {
lbClient.close();
}
-
- if (clientIsInternal && myClient!=null) {
+
+ if (clientIsInternal && myClient != null) {
HttpClientUtil.close(myClient);
}
@@ -135,17 +150,18 @@ public class CloudSolrClient extends BaseCloudSolrClient {
return myClient;
}
- public ClusterStateProvider getClusterStateProvider(){
+ public ClusterStateProvider getClusterStateProvider() {
return stateProvider;
}
@Override
protected boolean wasCommError(Throwable rootCause) {
- return rootCause instanceof ConnectTimeoutException ||
- rootCause instanceof NoHttpResponseException;
+ return rootCause instanceof ConnectTimeoutException
+ || rootCause instanceof NoHttpResponseException;
}
- private static LBHttpSolrClient createLBHttpSolrClient(Builder cloudSolrClientBuilder, HttpClient httpClient) {
+ private static LBHttpSolrClient createLBHttpSolrClient(
+ Builder cloudSolrClientBuilder, HttpClient httpClient) {
final LBHttpSolrClient.Builder lbBuilder = new LBHttpSolrClient.Builder();
lbBuilder.withHttpClient(httpClient);
if (cloudSolrClientBuilder.connectionTimeoutMillis != null) {
@@ -157,13 +173,11 @@ public class CloudSolrClient extends BaseCloudSolrClient {
final LBHttpSolrClient lbClient = lbBuilder.build();
lbClient.setRequestWriter(new BinaryRequestWriter());
lbClient.setParser(new BinaryResponseParser());
-
+
return lbClient;
}
- /**
- * Constructs {@link CloudSolrClient} instances from provided configuration.
- */
+ /** Constructs {@link CloudSolrClient} instances from provided configuration. */
public static class Builder extends SolrClientBuilder<Builder> {
protected Collection<String> zkHosts = new ArrayList<>();
protected List<String> solrUrls = new ArrayList<>();
@@ -174,20 +188,20 @@ public class CloudSolrClient extends BaseCloudSolrClient {
protected boolean directUpdatesToLeadersOnly = false;
protected boolean parallelUpdates = true;
protected ClusterStateProvider stateProvider;
-
- /**
- * Constructor for use by subclasses. This constructor was public prior to version 9.0
- */
+
+ /** Constructor for use by subclasses. This constructor was public prior to version 9.0 */
protected Builder() {}
/**
* Provide a series of Solr URLs to be used when configuring {@link CloudSolrClient} instances.
- * The solr client will use these urls to understand the cluster topology, which solr nodes are active etc.
- *
- * Provided Solr URLs are expected to point to the root Solr path ("http://hostname:8983/solr"); they should not
- * include any collections, cores, or other path components.
+ * The solr client will use these urls to understand the cluster topology, which solr nodes are
+ * active etc.
+ *
+ * <p>Provided Solr URLs are expected to point to the root Solr path
+ * ("http://hostname:8983/solr"); they should not include any collections, cores, or other path
+ * components.
*
- * Usage example:
+ * <p>Usage example:
*
* <pre>
* final List<String> solrBaseUrls = new ArrayList<String>();
@@ -199,17 +213,16 @@ public class CloudSolrClient extends BaseCloudSolrClient {
this.solrUrls = solrUrls;
}
- /**
- * Provide an already created {@link ClusterStateProvider} instance
- */
+ /** Provide an already created {@link ClusterStateProvider} instance */
public Builder(ClusterStateProvider stateProvider) {
this.stateProvider = stateProvider;
}
/**
- * Provide a series of ZK hosts which will be used when configuring {@link CloudSolrClient} instances.
+ * Provide a series of ZK hosts which will be used when configuring {@link CloudSolrClient}
+ * instances.
*
- * Usage example when Solr stores data at the ZooKeeper root ('/'):
+ * <p>Usage example when Solr stores data at the ZooKeeper root ('/'):
*
* <pre>
* final List<String> zkServers = new ArrayList<String>();
@@ -219,31 +232,28 @@ public class CloudSolrClient extends BaseCloudSolrClient {
*
* Usage example when Solr data is stored in a ZooKeeper chroot:
*
- * <pre>
+ * <pre>
* final List<String> zkServers = new ArrayList<String>();
* zkServers.add("zookeeper1:2181"); zkServers.add("zookeeper2:2181"); zkServers.add("zookeeper3:2181");
* final SolrClient client = new CloudSolrClient.Builder(zkServers, Optional.of("/solr")).build();
* </pre>
*
* @param zkHosts a List of at least one ZooKeeper host and port (e.g. "zookeeper1:2181")
- * @param zkChroot the path to the root ZooKeeper node containing Solr data. Provide {@code java.util.Optional.empty()} if no ZK chroot is used.
+ * @param zkChroot the path to the root ZooKeeper node containing Solr data. Provide {@code
+ * java.util.Optional.empty()} if no ZK chroot is used.
*/
public Builder(List<String> zkHosts, Optional<String> zkChroot) {
this.zkHosts = zkHosts;
if (zkChroot.isPresent()) this.zkChroot = zkChroot.get();
}
- /**
- * Provides a {@link HttpClient} for the builder to use when creating clients.
- */
+ /** Provides a {@link HttpClient} for the builder to use when creating clients. */
public Builder withLBHttpSolrClientBuilder(LBHttpSolrClient.Builder lbHttpSolrClientBuilder) {
this.lbClientBuilder = lbHttpSolrClientBuilder;
return this;
}
- /**
- * Provides a {@link LBHttpSolrClient} for the builder to use when creating clients.
- */
+ /** Provides a {@link LBHttpSolrClient} for the builder to use when creating clients. */
public Builder withLBHttpSolrClient(LBHttpSolrClient loadBalancedSolrClient) {
this.loadBalancedSolrClient = loadBalancedSolrClient;
return this;
@@ -252,17 +262,17 @@ public class CloudSolrClient extends BaseCloudSolrClient {
/**
* Tells {@link Builder} that created clients should send updates only to shard leaders.
*
- * WARNING: This method currently has no effect. See SOLR-6312 for more information.
+ * <p>WARNING: This method currently has no effect. See SOLR-6312 for more information.
*/
public Builder sendUpdatesOnlyToShardLeaders() {
shardLeadersOnly = true;
return this;
}
-
+
/**
* Tells {@link Builder} that created clients should send updates to all replicas for a shard.
*
- * WARNING: This method currently has no effect. See SOLR-6312 for more information.
+ * <p>WARNING: This method currently has no effect. See SOLR-6312 for more information.
*/
public Builder sendUpdatesToAllReplicasInShard() {
shardLeadersOnly = false;
@@ -272,7 +282,8 @@ public class CloudSolrClient extends BaseCloudSolrClient {
/**
* Tells {@link Builder} that created clients should send direct updates to shard leaders only.
*
- * UpdateRequests whose leaders cannot be found will "fail fast" on the client side with a {@link SolrException}
+ * <p>UpdateRequests whose leaders cannot be found will "fail fast" on the client side with a
+ * {@link SolrException}
*/
public Builder sendDirectUpdatesToShardLeadersOnly() {
directUpdatesToLeadersOnly = true;
@@ -280,10 +291,11 @@ public class CloudSolrClient extends BaseCloudSolrClient {
}
/**
- * Tells {@link Builder} that created clients can send updates to any shard replica (shard leaders and non-leaders).
+ * Tells {@link Builder} that created clients can send updates to any shard replica (shard
+ * leaders and non-leaders).
*
- * Shard leaders are still preferred, but the created clients will fallback to using other replicas if a leader
- * cannot be found.
+ * <p>Shard leaders are still preferred, but the created clients will fallback to using other
+ * replicas if a leader cannot be found.
*/
public Builder sendDirectUpdatesToAnyShardReplica() {
directUpdatesToLeadersOnly = false;
@@ -291,32 +303,35 @@ public class CloudSolrClient extends BaseCloudSolrClient {
}
/**
- * Tells {@link Builder} whether created clients should send shard updates serially or in parallel
+ * Tells {@link Builder} whether created clients should send shard updates serially or in
+ * parallel
+ *
+ * <p>When an {@link UpdateRequest} affects multiple shards, {@link CloudSolrClient} splits it
+ * up and sends a request to each affected shard. This setting chooses whether those
+ * sub-requests are sent serially or in parallel.
*
- * When an {@link UpdateRequest} affects multiple shards, {@link CloudSolrClient} splits it up and sends a request
- * to each affected shard. This setting chooses whether those sub-requests are sent serially or in parallel.
- * <p>
- * If not set, this defaults to 'true' and sends sub-requests in parallel.
+ * <p>If not set, this defaults to 'true' and sends sub-requests in parallel.
*/
public Builder withParallelUpdates(boolean parallelUpdates) {
this.parallelUpdates = parallelUpdates;
return this;
}
- /**
- * Create a {@link CloudSolrClient} based on the provided configuration.
- */
+ /** Create a {@link CloudSolrClient} based on the provided configuration. */
public CloudSolrClient build() {
if (stateProvider == null) {
if (!zkHosts.isEmpty()) {
stateProvider = new ZkClientClusterStateProvider(zkHosts, zkChroot);
- }
- else if (!this.solrUrls.isEmpty()) {
+ } else if (!this.solrUrls.isEmpty()) {
try {
stateProvider = new HttpClusterStateProvider(solrUrls, httpClient);
} catch (Exception e) {
- throw new RuntimeException("Couldn't initialize a HttpClusterStateProvider (is/are the "
- + "Solr server(s), " + solrUrls + ", down?)", e);
+ throw new RuntimeException(
+ "Couldn't initialize a HttpClusterStateProvider (is/are the "
+ + "Solr server(s), "
+ + solrUrls
+ + ", down?)",
+ e);
}
} else {
throw new IllegalArgumentException("Both zkHosts and solrUrl cannot be null.");
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ClusterStateProvider.java
index e7441dc..f858ef8 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ClusterStateProvider.java
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import org.apache.solr.common.SolrCloseable;
import org.apache.solr.common.cloud.ClusterState;
import org.apache.solr.common.cloud.DocCollection;
@@ -30,83 +29,74 @@ public interface ClusterStateProvider extends SolrCloseable {
/**
* Obtain the state of the collection (cluster status).
+ *
* @return the collection state, or null is collection doesn't exist
*/
ClusterState.CollectionRef getState(String collection);
- /**
- * Obtain set of live_nodes for the cluster.
- */
+ /** Obtain set of live_nodes for the cluster. */
Set<String> getLiveNodes();
/**
- * Given a collection alias, returns a list of collections it points to, or returns a singleton list of the input if
- * it's not an alias.
+ * Given a collection alias, returns a list of collections it points to, or returns a singleton
+ * list of the input if it's not an alias.
*/
List<String> resolveAlias(String alias);
- /**
- * Return alias properties, or an empty map if the alias has no properties.
- */
+ /** Return alias properties, or an empty map if the alias has no properties. */
Map<String, String> getAliasProperties(String alias);
/**
- * Given a collection alias, return a single collection it points to, or the original name if it's not an
- * alias.
- * @throws IllegalArgumentException if an alias points to more than 1 collection, either directly or indirectly.
+ * Given a collection alias, return a single collection it points to, or the original name if it's
+ * not an alias.
+ *
+ * @throws IllegalArgumentException if an alias points to more than 1 collection, either directly
+ * or indirectly.
*/
default String resolveSimpleAlias(String alias) throws IllegalArgumentException {
List<String> aliases = resolveAlias(alias);
if (aliases.size() > 1) {
- throw new IllegalArgumentException("Simple alias '" + alias + "' points to more than 1 collection: " + aliases);
+ throw new IllegalArgumentException(
+ "Simple alias '" + alias + "' points to more than 1 collection: " + aliases);
}
return aliases.get(0);
}
- /**
- * Returns true if an alias exists and is a routed alias, false otherwise.
- */
+ /** Returns true if an alias exists and is a routed alias, false otherwise. */
default boolean isRoutedAlias(String alias) {
- return getAliasProperties(alias).entrySet().stream().anyMatch(e -> e.getKey().startsWith(CollectionAdminParams.ROUTER_PREFIX));
+ return getAliasProperties(alias).entrySet().stream()
+ .anyMatch(e -> e.getKey().startsWith(CollectionAdminParams.ROUTER_PREFIX));
}
- /**
- * Obtain the current cluster state.
- */
+ /** Obtain the current cluster state. */
ClusterState getClusterState() throws IOException;
- default DocCollection getCollection(String name) throws IOException{
- return getClusterState().getCollectionOrNull(name);
+ default DocCollection getCollection(String name) throws IOException {
+ return getClusterState().getCollectionOrNull(name);
}
/**
* Obtain cluster properties.
+ *
* @return configured cluster properties, or an empty map, never null.
*/
Map<String, Object> getClusterProperties();
- /**
- * Obtain a cluster property, or the default value if it doesn't exist.
- */
+ /** Obtain a cluster property, or the default value if it doesn't exist. */
default <T> T getClusterProperty(String key, T defaultValue) {
@SuppressWarnings({"unchecked"})
T value = (T) getClusterProperties().get(key);
- if (value == null)
- return defaultValue;
+ if (value == null) return defaultValue;
return value;
}
- /**
- * Obtain a cluster property, or null if it doesn't exist.
- */
+ /** Obtain a cluster property, or null if it doesn't exist. */
default Object getClusterProperty(String propertyName) {
return getClusterProperties().get(propertyName);
}
- /**
- * Get the collection-specific policy
- */
+ /** Get the collection-specific policy */
String getPolicyNameByCollection(String coll);
void connect();
-}
\ No newline at end of file
+}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
index a705121..f0b5240 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
@@ -29,7 +29,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
-
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
@@ -48,9 +47,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-/**
- * @lucene.experimental
- */
+/** @lucene.experimental */
public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -71,7 +68,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
private volatile boolean closed;
private volatile CountDownLatch lock = null; // used to block everything
- private static class CustomBlockingQueue<E> implements Iterable<E>{
+ private static class CustomBlockingQueue<E> implements Iterable<E> {
private final BlockingQueue<E> queue;
private final Semaphore available;
private final int queueSize;
@@ -109,8 +106,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
if (e == null) {
return null;
}
- if (e == backdoorE)
- return null;
+ if (e == backdoorE) return null;
available.release();
return e;
}
@@ -153,29 +149,30 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
this.basePath = builder.baseSolrUrl;
this.stallTime = Integer.getInteger("solr.cloud.client.stallTime", 15000);
if (stallTime < pollQueueTime * 2) {
- throw new RuntimeException("Invalid stallTime: " + stallTime + "ms, must be 2x > pollQueueTime " + pollQueueTime);
+ throw new RuntimeException(
+ "Invalid stallTime: " + stallTime + "ms, must be 2x > pollQueueTime " + pollQueueTime);
}
if (builder.executorService != null) {
this.scheduler = builder.executorService;
this.shutdownExecutor = false;
} else {
- this.scheduler = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("concurrentUpdateScheduler"));
+ this.scheduler =
+ ExecutorUtil.newMDCAwareCachedThreadPool(
+ new SolrNamedThreadFactory("concurrentUpdateScheduler"));
this.shutdownExecutor = true;
}
-
}
- /**
- * Opens a connection and sends everything...
- */
+ /** Opens a connection and sends everything... */
class Runner implements Runnable {
@Override
public void run() {
log.debug("starting runner: {}", this);
- // This loop is so we can continue if an element was added to the queue after the last runner exited.
- for (;;) {
+ // This loop is so we can continue if an element was added to the queue after the last runner
+ // exited.
+ for (; ; ) {
try {
sendUpdateStream();
@@ -189,7 +186,8 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
synchronized (runners) {
// check to see if anything else was added to the queue
if (runners.size() == 1 && !queue.isEmpty() && !scheduler.isShutdown()) {
- // If there is something else to process, keep last runner alive by staying in the loop.
+ // If there is something else to process, keep last runner alive by staying in the
+ // loop.
} else {
runners.remove(this);
if (runners.isEmpty()) {
@@ -225,13 +223,14 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
InputStreamResponseListener responseListener = null;
- try (Http2SolrClient.OutStream out = client.initOutStream(basePath, update.getRequest(),
- update.getCollection())) {
+ try (Http2SolrClient.OutStream out =
+ client.initOutStream(basePath, update.getRequest(), update.getCollection())) {
Update upd = update;
while (upd != null) {
UpdateRequest req = upd.getRequest();
if (!out.belongToThisStream(req, upd.getCollection())) {
- queue.add(upd); // Request has different params or destination core/collection, return to queue
+ // Request has different params or destination core/collection, return to queue
+ queue.add(upd);
break;
}
client.send(out, upd.getRequest(), upd.getCollection());
@@ -243,7 +242,8 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
responseListener = out.getResponseListener();
}
- Response response = responseListener.get(client.getIdleTimeout(), TimeUnit.MILLISECONDS);
+ Response response =
+ responseListener.get(client.getIdleTimeout(), TimeUnit.MILLISECONDS);
rspBody = responseListener.getInputStream();
int statusCode = response.getStatus();
@@ -272,7 +272,9 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
// don't want to fail to report error if parsing the response fails
log.warn("Failed to parse error response from {} due to: ", basePath, exc);
} finally {
- solrExc = new BaseHttpSolrClient.RemoteSolrException(basePath , statusCode, msg.toString(), null);
+ solrExc =
+ new BaseHttpSolrClient.RemoteSolrException(
+ basePath, statusCode, msg.toString(), null);
if (metadata != null) {
solrExc.setMetadata(metadata);
}
@@ -295,7 +297,6 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
} catch (InterruptedException e) {
log.error("Interrupted on polling from queue", e);
}
-
}
}
@@ -304,8 +305,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
try (is) {
// make sure the stream is full read
is.skip(is.available());
- while (is.read() != -1) {
- }
+ while (is.read() != -1) {}
} catch (UnsupportedOperationException e) {
// nothing to do then
} catch (IOException e) {
@@ -322,7 +322,8 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
synchronized (runners) {
// we notify runners too - if there is a high queue poll time and this is the update
- // that emptied the queue, we make an attempt to avoid the 250ms timeout in blockUntilFinished
+ // that emptied the queue, we make an attempt to avoid the 250ms timeout in
+ // blockUntilFinished
runners.notifyAll();
}
}
@@ -330,12 +331,16 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
// *must* be called with runners monitor held, e.g. synchronized(runners){ addRunner() }
private void addRunner() {
- MDC.put("ConcurrentUpdateHttp2SolrClient.url", String.valueOf(client.getBaseURL())); // MDC can't have null value
+ MDC.put(
+ "ConcurrentUpdateHttp2SolrClient.url",
+ String.valueOf(client.getBaseURL())); // MDC can't have null value
try {
Runner r = new Runner();
runners.add(r);
try {
- scheduler.execute(r); // this can throw an exception if the scheduler has been shutdown, but that should be fine.
+ // this can throw an exception if the scheduler has been shutdown, but that should
+ // be fine.
+ scheduler.execute(r);
} catch (RuntimeException e) {
runners.remove(r);
throw e;
@@ -371,7 +376,6 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
}
-
SolrParams params = req.getParams();
if (params != null) {
// check if it is waiting for the searcher
@@ -393,13 +397,13 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
long lastStallTime = -1;
int lastQueueSize = -1;
- for (;;) {
+ for (; ; ) {
synchronized (runners) {
// see if queue is half full and we can add more runners
// special case: if only using a threadCount of 1 and the queue
// is filling up, allow 1 add'l runner to help process the queue
- if (runners.isEmpty() || (queue.remainingCapacity() < queue.size() && runners.size() < threadCount))
- {
+ if (runners.isEmpty()
+ || (queue.remainingCapacity() < queue.size() && runners.size() < threadCount)) {
// We need more runners, so start a new one.
addRunner();
} else {
@@ -407,8 +411,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
// successfully, *and*
// while we are still holding the runners lock to prevent race
// conditions.
- if (success)
- break;
+ if (success) break;
}
}
@@ -438,9 +441,15 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
// mark a stall but keep trying
lastStallTime = System.nanoTime();
} else {
- long currentStallTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
+ long currentStallTime =
+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
if (currentStallTime > stallTime) {
- throw new IOException("Request processing has stalled for " + currentStallTime + "ms with " + queue.size() + " remaining elements in the queue.");
+ throw new IOException(
+ "Request processing has stalled for "
+ + currentStallTime
+ + "ms with "
+ + queue.size()
+ + " remaining elements in the queue.");
}
}
}
@@ -469,18 +478,18 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
synchronized (runners) {
- // NOTE: if the executor is shut down, runners may never become empty (a scheduled task may never be run,
- // which means it would never remove itself from the runners list. This is why we don't wait forever
- // and periodically check if the scheduler is shutting down.
+ // NOTE: if the executor is shut down, runners may never become empty (a scheduled task may
+ // never be run, which means it would never remove itself from the runners list. This is why
+ // we don't wait forever and periodically check if the scheduler is shutting down.
int loopCount = 0;
while (!runners.isEmpty()) {
- if (scheduler.isShutdown())
- break;
+ if (scheduler.isShutdown()) break;
loopCount++;
- // Need to check if the queue is empty before really considering this is finished (SOLR-4260)
+ // Need to check if the queue is empty before really considering this is finished
+ // (SOLR-4260)
int queueSize = queue.size();
// stall prevention
if (lastQueueSize != queueSize) {
@@ -491,18 +500,25 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
if (lastStallTime == -1) {
lastStallTime = System.nanoTime();
} else {
- long currentStallTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
+ long currentStallTime =
+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
if (currentStallTime > stallTime) {
- throw new IOException("Task queue processing has stalled for " + currentStallTime + " ms with " + queueSize + " remaining elements to process.");
-// Thread.currentThread().interrupt();
-// break;
+ throw new IOException(
+ "Task queue processing has stalled for "
+ + currentStallTime
+ + " ms with "
+ + queueSize
+ + " remaining elements to process.");
+ // Thread.currentThread().interrupt();
+ // break;
}
}
}
if (queueSize > 0 && runners.isEmpty()) {
// TODO: can this still happen?
- log.warn("No more runners, but queue still has {} adding more runners to process remaining requests on queue"
- , queueSize);
+ log.warn(
+ "No more runners, but queue still has {} adding more runners to process remaining requests on queue",
+ queueSize);
addRunner();
}
@@ -539,16 +555,21 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
int lastQueueSize = -1;
while (!queue.isEmpty()) {
if (scheduler.isTerminated()) {
- log.warn("The task queue still has elements but the update scheduler {} is terminated. Can't process any more tasks. Queue size: {}, Runners: {}. Current thread Interrupted? {}"
- , scheduler, queue.size(), runners.size(), threadInterrupted);
+ log.warn(
+ "The task queue still has elements but the update scheduler {} is terminated. Can't process any more tasks. Queue size: {}, Runners: {}. Current thread Interrupted? {}",
+ scheduler,
+ queue.size(),
+ runners.size(),
+ threadInterrupted);
break;
}
synchronized (runners) {
int queueSize = queue.size();
if (queueSize > 0 && runners.isEmpty()) {
- log.warn("No more runners, but queue still has {} adding more runners to process remaining requests on queue"
- , queueSize);
+ log.warn(
+ "No more runners, but queue still has {} adding more runners to process remaining requests on queue",
+ queueSize);
addRunner();
}
}
@@ -556,9 +577,11 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
try {
queue.wait(250);
} catch (InterruptedException e) {
- // If we set the thread as interrupted again, the next time the wait it's called i t's going to return immediately
+ // If we set the thread as interrupted again, the next time the wait it's called i t's
+ // going to return immediately
threadInterrupted = true;
- log.warn("Thread interrupted while waiting for update queue to be empty. There are still {} elements in the queue.",
+ log.warn(
+ "Thread interrupted while waiting for update queue to be empty. There are still {} elements in the queue.",
queue.size());
}
}
@@ -574,9 +597,14 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
} else {
long currentStallTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
if (currentStallTime > stallTime) {
- throw new IOException("Task queue processing has stalled for " + currentStallTime + " ms with " + currentQueueSize + " remaining elements to process.");
-// threadInterrupted = true;
-// break;
+ throw new IOException(
+ "Task queue processing has stalled for "
+ + currentStallTime
+ + " ms with "
+ + currentQueueSize
+ + " remaining elements to process.");
+ // threadInterrupted = true;
+ // break;
}
}
}
@@ -592,6 +620,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
/**
* Intended to be used as an extension point for doing post processing after a request completes.
+ *
* @param respBody the body of the response, subclasses must not close this stream.
*/
public void onSuccess(Response resp, InputStream respBody) {
@@ -613,8 +642,8 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
try {
if (!scheduler.awaitTermination(60, TimeUnit.SECONDS)) {
scheduler.shutdownNow();
- if (!scheduler.awaitTermination(60, TimeUnit.SECONDS)) log
- .error("ExecutorService did not terminate");
+ if (!scheduler.awaitTermination(60, TimeUnit.SECONDS))
+ log.error("ExecutorService did not terminate");
}
} catch (InterruptedException ie) {
scheduler.shutdownNow();
@@ -624,8 +653,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
interruptRunnerThreadsPolling();
}
} finally {
- if (shutdownClient)
- client.close();
+ if (shutdownClient) client.close();
}
}
@@ -660,8 +688,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
/**
- * @param pollQueueTime time for an open connection to wait for updates when
- * the queue is empty.
+ * @param pollQueueTime time for an open connection to wait for updates when the queue is empty.
*/
public void setPollQueueTime(int pollQueueTime) {
this.pollQueueTime = pollQueueTime;
@@ -673,9 +700,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
}
- /**
- * Constructs {@link ConcurrentUpdateHttp2SolrClient} instances from provided configuration.
- */
+ /** Constructs {@link ConcurrentUpdateHttp2SolrClient} instances from provided configuration. */
public static class Builder {
protected Http2SolrClient client;
protected String baseSolrUrl;
@@ -696,13 +721,16 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
/**
- * The maximum number of requests buffered by the SolrClient's internal queue before being processed by background threads.
+ * The maximum number of requests buffered by the SolrClient's internal queue before being
+ * processed by background threads.
*
- * This value should be carefully paired with the number of queue-consumer threads. A queue with a maximum size
- * set too high may require more memory. A queue with a maximum size set too low may suffer decreased throughput
- * as {@link ConcurrentUpdateHttp2SolrClient#request(SolrRequest)} calls block waiting to add requests to the queue.
+ * <p>This value should be carefully paired with the number of queue-consumer threads. A queue
+ * with a maximum size set too high may require more memory. A queue with a maximum size set too
+ * low may suffer decreased throughput as {@link
+ * ConcurrentUpdateHttp2SolrClient#request(SolrRequest)} calls block waiting to add requests to
+ * the queue.
*
- * If not set, this defaults to 10.
+ * <p>If not set, this defaults to 10.
*
* @see #withThreadCount(int)
*/
@@ -717,12 +745,13 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
/**
* The maximum number of threads used to empty {@link ConcurrentUpdateHttp2SolrClient}s queue.
*
- * Threads are created when documents are added to the client's internal queue and exit when no updates remain in
+ * <p>Threads are created when documents are added to the client's internal queue and exit when
+ * no updates remain in the queue.
+ *
+ * <p>This value should be carefully paired with the maximum queue capacity. A client with too
+ * few threads may suffer decreased throughput as the queue fills up and {@link
+ * ConcurrentUpdateHttp2SolrClient#request(SolrRequest)} calls block waiting to add requests to
* the queue.
- * <p>
- * This value should be carefully paired with the maximum queue capacity. A client with too few threads may suffer
- * decreased throughput as the queue fills up and {@link ConcurrentUpdateHttp2SolrClient#request(SolrRequest)} calls
- * block waiting to add requests to the queue.
*/
public Builder withThreadCount(int threadCount) {
if (threadCount <= 0) {
@@ -734,7 +763,8 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
/**
- * Provides the {@link ExecutorService} for the created client to use when servicing the update-request queue.
+ * Provides the {@link ExecutorService} for the created client to use when servicing the
+ * update-request queue.
*/
public Builder withExecutorService(ExecutorService executorService) {
this.executorService = executorService;
@@ -744,7 +774,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
/**
* Configures created clients to always stream delete requests.
*
- * Streamed deletes are put into the update-queue and executed like any other update request.
+ * <p>Streamed deletes are put into the update-queue and executed like any other update request.
*/
public Builder alwaysStreamDeletes() {
this.streamDeletes = true;
@@ -754,8 +784,9 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
/**
* Configures created clients to not stream delete requests.
*
- * With this option set when the created ConcurrentUpdateHttp2SolrClient sents a delete request it will first will lock
- * the queue and block until all queued updates have been sent, and then send the delete request.
+ * <p>With this option set when the created ConcurrentUpdateHttp2SolrClient sents a delete
+ * request it will first will lock the queue and block until all queued updates have been sent,
+ * and then send the delete request.
*/
public Builder neverStreamDeletes() {
this.streamDeletes = false;
@@ -767,11 +798,11 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
*/
public ConcurrentUpdateHttp2SolrClient build() {
if (baseSolrUrl == null) {
- throw new IllegalArgumentException("Cannot create HttpSolrClient without a valid baseSolrUrl!");
+ throw new IllegalArgumentException(
+ "Cannot create HttpSolrClient without a valid baseSolrUrl!");
}
return new ConcurrentUpdateHttp2SolrClient(this);
}
-
}
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
index b9ac1d5..d845b05 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
@@ -16,6 +16,21 @@
*/
package org.apache.solr.client.solrj.impl;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.invoke.MethodHandles;
+import java.nio.charset.StandardCharsets;
+import java.util.LinkedList;
+import java.util.Locale;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
@@ -44,34 +59,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.invoke.MethodHandles;
-import java.nio.charset.StandardCharsets;
-import java.util.LinkedList;
-import java.util.Locale;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
/**
- * ConcurrentUpdateSolrClient buffers all added documents and writes
- * them into open HTTP connections. This class is thread safe.
- *
- * Params from {@link UpdateRequest} are converted to http request
- * parameters. When params change between UpdateRequests a new HTTP
- * request is started.
- *
- * Although any SolrClient request can be made with this implementation, it is
- * only recommended to use ConcurrentUpdateSolrClient with /update
- * requests. The class {@link HttpSolrClient} is better suited for the
- * query interface.
+ * ConcurrentUpdateSolrClient buffers all added documents and writes them into open HTTP
+ * connections. This class is thread safe.
+ *
+ * <p>Params from {@link UpdateRequest} are converted to http request parameters. When params change
+ * between UpdateRequests a new HTTP request is started.
+ *
+ * <p>Although any SolrClient request can be made with this implementation, it is only recommended
+ * to use ConcurrentUpdateSolrClient with /update requests. The class {@link HttpSolrClient} is
+ * better suited for the query interface.
*/
public class ConcurrentUpdateSolrClient extends SolrClient {
private static final long serialVersionUID = 1L;
@@ -90,23 +87,24 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
private volatile Integer connectionTimeout;
private volatile Integer soTimeout;
private volatile boolean closed;
-
+
AtomicInteger pollInterrupts;
AtomicInteger pollExits;
AtomicInteger blockLoops;
AtomicInteger emptyQueueLoops;
-
+
/**
- * Use builder to construct this class.
- * Uses the supplied HttpClient to send documents to the Solr server.
+ * Use builder to construct this class. Uses the supplied HttpClient to send documents to the Solr
+ * server.
*/
protected ConcurrentUpdateSolrClient(Builder builder) {
this.internalHttpClient = (builder.httpClient == null);
- this.client = new HttpSolrClient.Builder(builder.baseSolrUrl)
- .withHttpClient(builder.httpClient)
- .withConnectionTimeout(builder.connectionTimeoutMillis)
- .withSocketTimeout(builder.socketTimeoutMillis)
- .build();
+ this.client =
+ new HttpSolrClient.Builder(builder.baseSolrUrl)
+ .withHttpClient(builder.httpClient)
+ .withConnectionTimeout(builder.connectionTimeoutMillis)
+ .withSocketTimeout(builder.socketTimeoutMillis)
+ .build();
this.client.setFollowRedirects(false);
this.queue = new LinkedBlockingQueue<>(builder.queueSize);
this.threadCount = builder.threadCount;
@@ -116,17 +114,20 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
this.soTimeout = builder.socketTimeoutMillis;
this.stallTime = Integer.getInteger("solr.cloud.client.stallTime", 15000);
if (stallTime < pollQueueTime * 2) {
- throw new RuntimeException("Invalid stallTime: " + stallTime + "ms, must be 2x > pollQueueTime " + pollQueueTime);
+ throw new RuntimeException(
+ "Invalid stallTime: " + stallTime + "ms, must be 2x > pollQueueTime " + pollQueueTime);
}
if (builder.executorService != null) {
this.scheduler = builder.executorService;
this.shutdownExecutor = false;
} else {
- this.scheduler = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("concurrentUpdateScheduler"));
+ this.scheduler =
+ ExecutorUtil.newMDCAwareCachedThreadPool(
+ new SolrNamedThreadFactory("concurrentUpdateScheduler"));
this.shutdownExecutor = true;
}
-
+
if (log.isDebugEnabled()) {
this.pollInterrupts = new AtomicInteger();
this.pollExits = new AtomicInteger();
@@ -141,30 +142,30 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
/**
* Expert Method.
+ *
* @param queryParams set of param keys to only send via the query string
*/
public void setQueryParams(Set<String> queryParams) {
this.client.setQueryParams(queryParams);
}
-
- /**
- * Opens a connection and sends everything...
- */
+
+ /** Opens a connection and sends everything... */
@SuppressWarnings({"unchecked"})
class Runner implements Runnable {
volatile Thread thread = null;
volatile boolean inPoll = false;
-
+
public Thread getThread() {
return thread;
}
-
+
@Override
public void run() {
this.thread = Thread.currentThread();
log.debug("starting runner: {}", this);
- // This loop is so we can continue if an element was added to the queue after the last runner exited.
- for (;;) {
+ // This loop is so we can continue if an element was added to the queue after the last runner
+ // exited.
+ for (; ; ) {
try {
sendUpdateStream();
@@ -178,7 +179,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
synchronized (runners) {
// check to see if anything else was added to the queue
if (runners.size() == 1 && !queue.isEmpty() && !scheduler.isShutdown()) {
- // If there is something else to process, keep last runner alive by staying in the loop.
+ // If there is something else to process, keep last runner alive by staying in the
+ // loop.
} else {
runners.remove(this);
if (runners.isEmpty()) {
@@ -200,18 +202,18 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
lthread.interrupt();
}
}
-
+
//
// Pull from the queue multiple times and streams over a single connection.
// Exits on exception, interruption, or an empty queue to pull from.
//
@SuppressWarnings({"unchecked"})
void sendUpdateStream() throws Exception {
-
+
while (!queue.isEmpty()) {
HttpPost method = null;
HttpResponse response = null;
-
+
InputStream rspBody = null;
try {
Update update;
@@ -225,85 +227,90 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
} finally {
inPoll = false;
}
- if (update == null)
- break;
+ if (update == null) break;
String contentType = client.requestWriter.getUpdateContentType();
final boolean isXml = ClientUtils.TEXT_XML.equals(contentType);
- final ModifiableSolrParams origParams = new ModifiableSolrParams(update.getRequest().getParams());
+ final ModifiableSolrParams origParams =
+ new ModifiableSolrParams(update.getRequest().getParams());
final String origTargetCollection = update.getCollection();
- EntityTemplate template = new EntityTemplate(new ContentProducer() {
-
- @Override
- public void writeTo(OutputStream out) throws IOException {
+ EntityTemplate template =
+ new EntityTemplate(
+ new ContentProducer() {
- if (isXml) {
- out.write("<stream>".getBytes(StandardCharsets.UTF_8)); // can be anything
- }
- Update upd = update;
- while (upd != null) {
- UpdateRequest req = upd.getRequest();
- SolrParams currentParams = new ModifiableSolrParams(req.getParams());
- if (!origParams.toNamedList().equals(currentParams.toNamedList()) || !StringUtils.equals(origTargetCollection, upd.getCollection())) {
- queue.add(upd); // Request has different params or destination core/collection, return to queue
- break;
- }
+ @Override
+ public void writeTo(OutputStream out) throws IOException {
- client.requestWriter.write(req, out);
- if (isXml) {
- // check for commit or optimize
- SolrParams params = req.getParams();
- if (params != null) {
- String fmt = null;
- if (params.getBool(UpdateParams.OPTIMIZE, false)) {
- fmt = "<optimize waitSearcher=\"%s\" />";
- } else if (params.getBool(UpdateParams.COMMIT, false)) {
- fmt = "<commit waitSearcher=\"%s\" />";
- }
- if (fmt != null) {
- byte[] content = String.format(Locale.ROOT,
- fmt, params.getBool(UpdateParams.WAIT_SEARCHER, false)
- + "")
- .getBytes(StandardCharsets.UTF_8);
- out.write(content);
- }
- }
- }
- out.flush();
-
- notifyQueueAndRunnersIfEmptyQueue();
- inPoll = true;
- try {
- while (true) {
- try {
- upd = queue.poll(pollQueueTime, TimeUnit.MILLISECONDS);
- break;
- } catch (InterruptedException e) {
- if (log.isDebugEnabled()) pollInterrupts.incrementAndGet();
- if (!queue.isEmpty()) {
- continue;
+ if (isXml) {
+ out.write("<stream>".getBytes(StandardCharsets.UTF_8)); // can be anything
+ }
+ Update upd = update;
+ while (upd != null) {
+ UpdateRequest req = upd.getRequest();
+ SolrParams currentParams = new ModifiableSolrParams(req.getParams());
+ if (!origParams.toNamedList().equals(currentParams.toNamedList())
+ || !StringUtils.equals(origTargetCollection, upd.getCollection())) {
+ // Request has different params or destination core/collection, return to
+ // queue
+ queue.add(upd);
+ break;
+ }
+
+ client.requestWriter.write(req, out);
+ if (isXml) {
+ // check for commit or optimize
+ SolrParams params = req.getParams();
+ if (params != null) {
+ String fmt = null;
+ if (params.getBool(UpdateParams.OPTIMIZE, false)) {
+ fmt = "<optimize waitSearcher=\"%s\" />";
+ } else if (params.getBool(UpdateParams.COMMIT, false)) {
+ fmt = "<commit waitSearcher=\"%s\" />";
+ }
+ if (fmt != null) {
+ byte[] content =
+ String.format(
+ Locale.ROOT,
+ fmt,
+ params.getBool(UpdateParams.WAIT_SEARCHER, false) + "")
+ .getBytes(StandardCharsets.UTF_8);
+ out.write(content);
+ }
+ }
+ }
+ out.flush();
+
+ notifyQueueAndRunnersIfEmptyQueue();
+ inPoll = true;
+ try {
+ while (true) {
+ try {
+ upd = queue.poll(pollQueueTime, TimeUnit.MILLISECONDS);
+ break;
+ } catch (InterruptedException e) {
+ if (log.isDebugEnabled()) pollInterrupts.incrementAndGet();
+ if (!queue.isEmpty()) {
+ continue;
+ }
+ if (log.isDebugEnabled()) pollExits.incrementAndGet();
+ upd = null;
+ break;
+ } finally {
+ inPoll = false;
+ }
+ }
+ } finally {
+ inPoll = false;
+ }
}
- if (log.isDebugEnabled()) pollExits.incrementAndGet();
- upd = null;
- break;
- } finally {
- inPoll = false;
- }
- }
- }finally {
- inPoll = false;
- }
- }
- if (isXml) {
- out.write("</stream>".getBytes(StandardCharsets.UTF_8));
- }
-
-
- }
- });
+ if (isXml) {
+ out.write("</stream>".getBytes(StandardCharsets.UTF_8));
+ }
+ }
+ });
// The parser 'wt=' and 'version=' params are used instead of the
// original params
@@ -312,32 +319,32 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
requestParams.set(CommonParams.VERSION, client.parser.getVersion());
String basePath = client.getBaseURL();
- if (update.getCollection() != null)
- basePath += "/" + update.getCollection();
+ if (update.getCollection() != null) basePath += "/" + update.getCollection();
+
+ method = new HttpPost(basePath + "/update" + requestParams.toQueryString());
- method = new HttpPost(basePath + "/update"
- + requestParams.toQueryString());
-
- org.apache.http.client.config.RequestConfig.Builder requestConfigBuilder = HttpClientUtil.createDefaultRequestConfigBuilder();
+ org.apache.http.client.config.RequestConfig.Builder requestConfigBuilder =
+ HttpClientUtil.createDefaultRequestConfigBuilder();
if (soTimeout != null) {
requestConfigBuilder.setSocketTimeout(soTimeout);
}
if (connectionTimeout != null) {
requestConfigBuilder.setConnectTimeout(connectionTimeout);
}
-
+
method.setConfig(requestConfigBuilder.build());
-
+
method.setEntity(template);
method.addHeader("User-Agent", HttpSolrClient.AGENT);
method.addHeader("Content-Type", contentType);
-
-
- response = client.getHttpClient()
- .execute(method, HttpClientUtil.createNewHttpClientRequestContext());
-
+
+ response =
+ client
+ .getHttpClient()
+ .execute(method, HttpClientUtil.createNewHttpClientRequestContext());
+
rspBody = response.getEntity().getContent();
-
+
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
StringBuilder msg = new StringBuilder();
@@ -351,8 +358,13 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
try {
String encoding = "UTF-8"; // default
if (response.getEntity().getContentType().getElements().length > 0) {
- NameValuePair param = response.getEntity().getContentType().getElements()[0].getParameterByName("charset");
- if (param != null) {
+ NameValuePair param =
+ response
+ .getEntity()
+ .getContentType()
+ .getElements()[0]
+ .getParameterByName("charset");
+ if (param != null) {
encoding = param.getValue();
}
}
@@ -370,7 +382,9 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
// don't want to fail to report error if parsing the response fails
log.warn("Failed to parse error response from {} due to: ", client.getBaseURL(), exc);
} finally {
- solrExc = new BaseHttpSolrClient.RemoteSolrException(client.getBaseURL(), statusCode, msg.toString(), null);
+ solrExc =
+ new BaseHttpSolrClient.RemoteSolrException(
+ client.getBaseURL(), statusCode, msg.toString(), null);
if (metadata != null) {
solrExc.setMetadata(metadata);
}
@@ -380,7 +394,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
} else {
onSuccess(response);
}
-
+
} finally {
try {
if (response != null) {
@@ -394,7 +408,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
}
}
-
+
private void notifyQueueAndRunnersIfEmptyQueue() {
if (queue.size() == 0) {
synchronized (queue) {
@@ -403,7 +417,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
synchronized (runners) {
// we notify runners too - if there is a high queue poll time and this is the update
- // that emptied the queue, we make an attempt to avoid the 250ms timeout in blockUntilFinished
+ // that emptied the queue, we make an attempt to avoid the 250ms timeout in
+ // blockUntilFinished
runners.notifyAll();
}
}
@@ -416,7 +431,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
Runner r = new Runner();
runners.add(r);
try {
- scheduler.execute(r); // this can throw an exception if the scheduler has been shutdown, but that should be fine.
+ // this can throw an exception if the scheduler has been shutdown, but that should be fine.
+ scheduler.execute(r);
} catch (RuntimeException e) {
runners.remove(r);
throw e;
@@ -426,14 +442,11 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
}
- /**
- * Class representing an UpdateRequest and an optional collection.
- */
+ /** Class representing an UpdateRequest and an optional collection. */
static class Update {
UpdateRequest request;
String collection;
/**
- *
* @param request the update request.
* @param collection The collection, can be null.
*/
@@ -441,21 +454,19 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
this.request = request;
this.collection = collection;
}
- /**
- * @return the update request.
- */
+ /** @return the update request. */
public UpdateRequest getRequest() {
return request;
}
+
public void setRequest(UpdateRequest request) {
this.request = request;
}
- /**
- * @return the collection, can be null.
- */
+ /** @return the collection, can be null. */
public String getCollection() {
return collection;
}
+
public void setCollection(String collection) {
this.collection = collection;
}
@@ -486,7 +497,6 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
}
-
SolrParams params = req.getParams();
if (params != null) {
// check if it is waiting for the searcher
@@ -508,13 +518,13 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
long lastStallTime = -1;
int lastQueueSize = -1;
- for (;;) {
+ for (; ; ) {
synchronized (runners) {
// see if queue is half full and we can add more runners
// special case: if only using a threadCount of 1 and the queue
// is filling up, allow 1 add'l runner to help process the queue
- if (runners.isEmpty() || (queue.remainingCapacity() < queue.size() && runners.size() < threadCount))
- {
+ if (runners.isEmpty()
+ || (queue.remainingCapacity() < queue.size() && runners.size() < threadCount)) {
// We need more runners, so start a new one.
addRunner();
} else {
@@ -522,8 +532,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
// successfully, *and*
// while we are still holding the runners lock to prevent race
// conditions.
- if (success)
- break;
+ if (success) break;
}
}
@@ -553,9 +562,15 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
// mark a stall but keep trying
lastStallTime = System.nanoTime();
} else {
- long currentStallTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
+ long currentStallTime =
+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
if (currentStallTime > stallTime) {
- throw new IOException("Request processing has stalled for " + currentStallTime + "ms with " + queue.size() + " remaining elements in the queue.");
+ throw new IOException(
+ "Request processing has stalled for "
+ + currentStallTime
+ + "ms with "
+ + queue.size()
+ + " remaining elements in the queue.");
}
}
}
@@ -584,20 +599,20 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
synchronized (runners) {
- // NOTE: if the executor is shut down, runners may never become empty (a scheduled task may never be run,
- // which means it would never remove itself from the runners list. This is why we don't wait forever
- // and periodically check if the scheduler is shutting down.
+ // NOTE: if the executor is shut down, runners may never become empty (a scheduled task may
+ // never be run, which means it would never remove itself from the runners list. This is why
+ // we don't wait forever and periodically check if the scheduler is shutting down.
int loopCount = 0;
while (!runners.isEmpty()) {
-
+
if (log.isDebugEnabled()) blockLoops.incrementAndGet();
-
- if (scheduler.isShutdown())
- break;
-
+
+ if (scheduler.isShutdown()) break;
+
loopCount++;
-
- // Need to check if the queue is empty before really considering this is finished (SOLR-4260)
+
+ // Need to check if the queue is empty before really considering this is finished
+ // (SOLR-4260)
int queueSize = queue.size();
// stall prevention
if (lastQueueSize != queueSize) {
@@ -608,23 +623,30 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
if (lastStallTime == -1) {
lastStallTime = System.nanoTime();
} else {
- long currentStallTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
+ long currentStallTime =
+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
if (currentStallTime > stallTime) {
- throw new IOException("Task queue processing has stalled for " + currentStallTime + " ms with " + queueSize + " remaining elements to process.");
-// Thread.currentThread().interrupt();
-// break;
+ throw new IOException(
+ "Task queue processing has stalled for "
+ + currentStallTime
+ + " ms with "
+ + queueSize
+ + " remaining elements to process.");
+ // Thread.currentThread().interrupt();
+ // break;
}
}
}
if (queueSize > 0 && runners.isEmpty()) {
// TODO: can this still happen?
- log.warn("No more runners, but queue still has {} adding more runners to process remaining requests on queue"
- , queueSize);
+ log.warn(
+ "No more runners, but queue still has {} adding more runners to process remaining requests on queue",
+ queueSize);
addRunner();
}
-
+
interruptRunnerThreadsPolling();
-
+
// try to avoid the worst case wait timeout
// without bad spin
int timeout;
@@ -635,7 +657,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
} else {
timeout = 250;
}
-
+
try {
runners.wait(timeout);
} catch (InterruptedException e) {
@@ -657,16 +679,21 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
while (!queue.isEmpty()) {
if (log.isDebugEnabled()) emptyQueueLoops.incrementAndGet();
if (scheduler.isTerminated()) {
- log.warn("The task queue still has elements but the update scheduler {} is terminated. Can't process any more tasks. Queue size: {}, Runners: {}. Current thread Interrupted? {}"
- , scheduler, queue.size(), runners.size(), threadInterrupted);
+ log.warn(
+ "The task queue still has elements but the update scheduler {} is terminated. Can't process any more tasks. Queue size: {}, Runners: {}. Current thread Interrupted? {}",
+ scheduler,
+ queue.size(),
+ runners.size(),
+ threadInterrupted);
break;
}
synchronized (runners) {
int queueSize = queue.size();
if (queueSize > 0 && runners.isEmpty()) {
- log.warn("No more runners, but queue still has {} adding more runners to process remaining requests on queue"
- , queueSize);
+ log.warn(
+ "No more runners, but queue still has {} adding more runners to process remaining requests on queue",
+ queueSize);
addRunner();
}
}
@@ -674,9 +701,11 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
try {
queue.wait(250);
} catch (InterruptedException e) {
- // If we set the thread as interrupted again, the next time the wait it's called it's going to return immediately
+ // If we set the thread as interrupted again, the next time the wait it's called it's
+ // going to return immediately
threadInterrupted = true;
- log.warn("Thread interrupted while waiting for update queue to be empty. There are still {} elements in the queue.",
+ log.warn(
+ "Thread interrupted while waiting for update queue to be empty. There are still {} elements in the queue.",
queue.size());
}
}
@@ -692,9 +721,14 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
} else {
long currentStallTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
if (currentStallTime > stallTime) {
- throw new IOException("Task queue processing has stalled for " + currentStallTime + " ms with " + currentQueueSize + " remaining elements to process.");
-// threadInterrupted = true;
-// break;
+ throw new IOException(
+ "Task queue processing has stalled for "
+ + currentStallTime
+ + " ms with "
+ + currentQueueSize
+ + " remaining elements to process.");
+ // threadInterrupted = true;
+ // break;
}
}
}
@@ -707,7 +741,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
public void handleError(Throwable ex) {
log.error("error", ex);
}
-
+
/**
* Intended to be used as an extension point for doing post processing after a request completes.
*/
@@ -722,7 +756,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
return;
}
closed = true;
-
+
try {
if (shutdownExecutor) {
scheduler.shutdown();
@@ -730,8 +764,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
try {
if (!scheduler.awaitTermination(60, TimeUnit.SECONDS)) {
scheduler.shutdownNow();
- if (!scheduler.awaitTermination(60, TimeUnit.SECONDS)) log
- .error("ExecutorService did not terminate");
+ if (!scheduler.awaitTermination(60, TimeUnit.SECONDS))
+ log.error("ExecutorService did not terminate");
}
} catch (InterruptedException ie) {
scheduler.shutdownNow();
@@ -743,7 +777,12 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
} finally {
if (internalHttpClient) IOUtils.closeQuietly(client);
if (log.isDebugEnabled()) {
- log.debug("STATS pollInteruppts={} pollExists={} blockLoops={} emptyQueueLoops={}", pollInterrupts.get(), pollExits.get(), blockLoops.get(), emptyQueueLoops.get());
+ log.debug(
+ "STATS pollInteruppts={} pollExists={} blockLoops={} emptyQueueLoops={}",
+ pollInterrupts.get(),
+ pollExits.get(),
+ blockLoops.get(),
+ emptyQueueLoops.get());
}
}
}
@@ -755,7 +794,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
}
}
-
+
public void shutdownNow() {
if (closed) {
return;
@@ -781,15 +820,13 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
if (internalHttpClient) IOUtils.closeQuietly(client);
}
}
-
+
public void setParser(ResponseParser responseParser) {
client.setParser(responseParser);
}
-
-
+
/**
- * @param pollQueueTime time for an open connection to wait for updates when
- * the queue is empty.
+ * @param pollQueueTime time for an open connection to wait for updates when the queue is empty.
*/
public void setPollQueueTime(int pollQueueTime) {
this.pollQueueTime = pollQueueTime;
@@ -804,10 +841,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
public void setRequestWriter(RequestWriter requestWriter) {
client.setRequestWriter(requestWriter);
}
-
- /**
- * Constructs {@link ConcurrentUpdateSolrClient} instances from provided configuration.
- */
+
+ /** Constructs {@link ConcurrentUpdateSolrClient} instances from provided configuration. */
public static class Builder extends SolrClientBuilder<Builder> {
protected String baseSolrUrl;
protected int queueSize = 10;
@@ -817,37 +852,45 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
/**
* Create a Builder object, based on the provided Solr URL.
- *
- * Two different paths can be specified as a part of this URL:
- *
- * 1) A path pointing directly at a particular core
+ *
+ * <p>Two different paths can be specified as a part of this URL:
+ *
+ * <p>1) A path pointing directly at a particular core
+ *
* <pre>
* SolrClient client = new ConcurrentUpdateSolrClient.Builder("http://my-solr-server:8983/solr/core1").build();
* QueryResponse resp = client.query(new SolrQuery("*:*"));
* </pre>
- * Note that when a core is provided in the base URL, queries and other requests can be made without mentioning the
- * core explicitly. However, the client can only send requests to that core.
- *
- * 2) The path of the root Solr path ("/solr")
+ *
+ * Note that when a core is provided in the base URL, queries and other requests can be made
+ * without mentioning the core explicitly. However, the client can only send requests to that
+ * core.
+ *
+ * <p>2) The path of the root Solr path ("/solr")
+ *
* <pre>
* SolrClient client = new ConcurrentUpdateSolrClient.Builder("http://my-solr-server:8983/solr").build();
* QueryResponse resp = client.query("core1", new SolrQuery("*:*"));
* </pre>
- * In this case the client is more flexible and can be used to send requests to any cores. This flexibility though
- * requires that the core be specified on all requests.
+ *
+ * In this case the client is more flexible and can be used to send requests to any cores. This
+ * flexibility though requires that the core be specified on all requests.
*/
public Builder(String baseSolrUrl) {
this.baseSolrUrl = baseSolrUrl;
}
-
+
/**
- * The maximum number of requests buffered by the SolrClient's internal queue before being processed by background threads.
+ * The maximum number of requests buffered by the SolrClient's internal queue before being
+ * processed by background threads.
*
- * This value should be carefully paired with the number of queue-consumer threads. A queue with a maximum size
- * set too high may require more memory. A queue with a maximum size set too low may suffer decreased throughput
- * as {@link ConcurrentUpdateSolrClient#request(SolrRequest)} calls block waiting to add requests to the queue.
+ * <p>This value should be carefully paired with the number of queue-consumer threads. A queue
+ * with a maximum size set too high may require more memory. A queue with a maximum size set too
+ * low may suffer decreased throughput as {@link
+ * ConcurrentUpdateSolrClient#request(SolrRequest)} calls block waiting to add requests to the
+ * queue.
*
- * If not set, this defaults to 10.
+ * <p>If not set, this defaults to 10.
*
* @see #withThreadCount(int)
*/
@@ -858,63 +901,65 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
this.queueSize = queueSize;
return this;
}
-
+
/**
* The maximum number of threads used to empty {@link ConcurrentUpdateSolrClient}s queue.
*
- * Threads are created when documents are added to the client's internal queue and exit when no updates remain in
- * the queue.
- * <p>
- * This value should be carefully paired with the maximum queue capacity. A client with too few threads may suffer
- * decreased throughput as the queue fills up and {@link ConcurrentUpdateSolrClient#request(SolrRequest)} calls
- * block waiting to add requests to the queue.
+ * <p>Threads are created when documents are added to the client's internal queue and exit when
+ * no updates remain in the queue.
+ *
+ * <p>This value should be carefully paired with the maximum queue capacity. A client with too
+ * few threads may suffer decreased throughput as the queue fills up and {@link
+ * ConcurrentUpdateSolrClient#request(SolrRequest)} calls block waiting to add requests to the
+ * queue.
*/
public Builder withThreadCount(int threadCount) {
if (threadCount <= 0) {
throw new IllegalArgumentException("threadCount must be a positive integer.");
}
-
+
this.threadCount = threadCount;
return this;
}
-
+
/**
- * Provides the {@link ExecutorService} for the created client to use when servicing the update-request queue.
+ * Provides the {@link ExecutorService} for the created client to use when servicing the
+ * update-request queue.
*/
public Builder withExecutorService(ExecutorService executorService) {
this.executorService = executorService;
return this;
}
-
+
/**
* Configures created clients to always stream delete requests.
*
- * Streamed deletes are put into the update-queue and executed like any other update request.
+ * <p>Streamed deletes are put into the update-queue and executed like any other update request.
*/
public Builder alwaysStreamDeletes() {
this.streamDeletes = true;
return this;
}
-
+
/**
* Configures created clients to not stream delete requests.
*
- * With this option set when the created ConcurrentUpdateSolrClient sents a delete request it will first will lock
- * the queue and block until all queued updates have been sent, and then send the delete request.
+ * <p>With this option set when the created ConcurrentUpdateSolrClient sents a delete request it
+ * will first will lock the queue and block until all queued updates have been sent, and then
+ * send the delete request.
*/
public Builder neverStreamDeletes() {
this.streamDeletes = false;
return this;
}
-
- /**
- * Create a {@link ConcurrentUpdateSolrClient} based on the provided configuration options.
- */
+
+ /** Create a {@link ConcurrentUpdateSolrClient} based on the provided configuration options. */
public ConcurrentUpdateSolrClient build() {
if (baseSolrUrl == null) {
- throw new IllegalArgumentException("Cannot create HttpSolrClient without a valid baseSolrUrl!");
+ throw new IllegalArgumentException(
+ "Cannot create HttpSolrClient without a valid baseSolrUrl!");
}
-
+
return new ConcurrentUpdateSolrClient(this);
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java
index b082810..4351b49 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java
@@ -16,24 +16,23 @@
*/
package org.apache.solr.client.solrj.impl;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.common.params.SolrParams;
-
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.common.params.SolrParams;
public class DelegationTokenHttpSolrClient extends HttpSolrClient {
- public final static String DELEGATION_TOKEN_PARAM = "delegation";
+ public static final String DELEGATION_TOKEN_PARAM = "delegation";
/**
- * Constructor for use by
- * {@linkplain org.apache.solr.client.solrj.impl.HttpSolrClient.Builder}.
+ * Constructor for use by {@linkplain org.apache.solr.client.solrj.impl.HttpSolrClient.Builder}.
+ *
* @lucene.internal
*/
protected DelegationTokenHttpSolrClient(Builder builder) {
@@ -42,7 +41,8 @@ public class DelegationTokenHttpSolrClient extends HttpSolrClient {
}
@Override
- protected HttpRequestBase createMethod(final SolrRequest<?> request, String collection) throws IOException, SolrServerException {
+ protected HttpRequestBase createMethod(final SolrRequest<?> request, String collection)
+ throws IOException, SolrServerException {
SolrParams params = request.getParams();
if (params != null && params.getParams(DELEGATION_TOKEN_PARAM) != null) {
throw new IllegalArgumentException(DELEGATION_TOKEN_PARAM + " parameter not supported");
@@ -52,8 +52,7 @@ public class DelegationTokenHttpSolrClient extends HttpSolrClient {
@Override
public void setQueryParams(Set<String> queryParams) {
- queryParams = queryParams == null ?
- Set.of(DELEGATION_TOKEN_PARAM): queryParams;
+ queryParams = queryParams == null ? Set.of(DELEGATION_TOKEN_PARAM) : queryParams;
if (!queryParams.contains(DELEGATION_TOKEN_PARAM)) {
queryParams = new HashSet<String>(queryParams);
queryParams.add(DELEGATION_TOKEN_PARAM);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java
index 335684a..f46fe1a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2ClusterStateProvider.java
@@ -19,15 +19,15 @@ package org.apache.solr.client.solrj.impl;
import java.io.IOException;
import java.util.List;
-
import org.apache.solr.client.solrj.SolrClient;
public class Http2ClusterStateProvider extends BaseHttpClusterStateProvider {
final Http2SolrClient httpClient;
final boolean closeClient;
- public Http2ClusterStateProvider(List<String> solrUrls, Http2SolrClient httpClient) throws Exception {
- this.httpClient = httpClient == null? new Http2SolrClient.Builder().build(): httpClient;
+ public Http2ClusterStateProvider(List<String> solrUrls, Http2SolrClient httpClient)
+ throws Exception {
+ this.httpClient = httpClient == null ? new Http2SolrClient.Builder().build() : httpClient;
this.closeClient = httpClient == null;
init(solrUrls);
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index 49bf7e6..afeacde 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -16,6 +16,10 @@
*/
package org.apache.solr.client.solrj.impl;
+import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteExecutionException;
+import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
+import static org.apache.solr.common.util.Utils.getObjectByPath;
+
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.IOException;
@@ -43,7 +47,6 @@ import java.util.concurrent.Phaser;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-
import org.apache.http.HttpStatus;
import org.apache.http.entity.ContentType;
import org.apache.solr.client.solrj.ResponseParser;
@@ -55,9 +58,9 @@ import org.apache.solr.client.solrj.embedded.SSLConfig;
import org.apache.solr.client.solrj.request.RequestWriter;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.request.V2Request;
+import org.apache.solr.client.solrj.util.AsyncListener;
import org.apache.solr.client.solrj.util.Cancellable;
import org.apache.solr.client.solrj.util.ClientUtils;
-import org.apache.solr.client.solrj.util.AsyncListener;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.StringUtils;
import org.apache.solr.common.params.CommonParams;
@@ -95,18 +98,17 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
-import static org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteExecutionException;
-import static org.apache.solr.common.util.Utils.getObjectByPath;
-
/**
* Difference between this {@link Http2SolrClient} and {@link HttpSolrClient}:
+ *
* <ul>
- * <li>{@link Http2SolrClient} sends requests in HTTP/2</li>
- * <li>{@link Http2SolrClient} can point to multiple urls</li>
- * <li>{@link Http2SolrClient} does not expose its internal httpClient like {@link HttpSolrClient#getHttpClient()},
- * sharing connection pools should be done by {@link Http2SolrClient.Builder#withHttpClient(Http2SolrClient)} </li>
+ * <li>{@link Http2SolrClient} sends requests in HTTP/2
+ * <li>{@link Http2SolrClient} can point to multiple urls
+ * <li>{@link Http2SolrClient} does not expose its internal httpClient like {@link
+ * HttpSolrClient#getHttpClient()}, sharing connection pools should be done by {@link
+ * Http2SolrClient.Builder#withHttpClient(Http2SolrClient)}
* </ul>
+ *
* @lucene.experimental
*/
public class Http2SolrClient extends SolrClient {
@@ -128,10 +130,9 @@ public class Http2SolrClient extends SolrClient {
private volatile RequestWriter requestWriter = new BinaryRequestWriter();
private List<HttpListenerFactory> listenerFactory = new LinkedList<>();
private AsyncTracker asyncTracker = new AsyncTracker();
- /**
- * The URL of the Solr server.
- */
+ /** The URL of the Solr server. */
private String serverBaseUrl;
+
private boolean closeClient;
private ExecutorService executor;
private boolean shutdownExecutor;
@@ -139,7 +140,7 @@ public class Http2SolrClient extends SolrClient {
private final String basicAuthAuthorizationStr;
protected Http2SolrClient(String serverBaseUrl, Builder builder) {
- if (serverBaseUrl != null) {
+ if (serverBaseUrl != null) {
if (!serverBaseUrl.equals("/") && serverBaseUrl.endsWith("/")) {
serverBaseUrl = serverBaseUrl.substring(0, serverBaseUrl.length() - 1);
}
@@ -160,7 +161,9 @@ public class Http2SolrClient extends SolrClient {
httpClient = builder.http2SolrClient.httpClient;
}
if (builder.basicAuthUser != null && builder.basicAuthPassword != null) {
- basicAuthAuthorizationStr = basicAuthCredentialsToAuthorizationString(builder.basicAuthUser, builder.basicAuthPassword);
+ basicAuthAuthorizationStr =
+ basicAuthCredentialsToAuthorizationString(
+ builder.basicAuthUser, builder.basicAuthPassword);
} else {
basicAuthAuthorizationStr = null;
}
@@ -187,8 +190,9 @@ public class Http2SolrClient extends SolrClient {
BlockingArrayQueue<Runnable> queue = new BlockingArrayQueue<>(256, 256);
executor = builder.executor;
if (executor == null) {
- this.executor = new ExecutorUtil.MDCAwareThreadPoolExecutor(32,
- 256, 60, TimeUnit.SECONDS, queue, new SolrNamedThreadFactory("h2sc"));
+ this.executor =
+ new ExecutorUtil.MDCAwareThreadPoolExecutor(
+ 32, 256, 60, TimeUnit.SECONDS, queue, new SolrNamedThreadFactory("h2sc"));
shutdownExecutor = true;
} else {
shutdownExecutor = false;
@@ -197,7 +201,9 @@ public class Http2SolrClient extends SolrClient {
SslContextFactory.Client sslContextFactory;
boolean sslEnabled;
if (builder.sslConfig == null) {
- sslEnabled = System.getProperty("javax.net.ssl.keyStore") != null || System.getProperty("javax.net.ssl.trustStore") != null;
+ sslEnabled =
+ System.getProperty("javax.net.ssl.keyStore") != null
+ || System.getProperty("javax.net.ssl.trustStore") != null;
sslContextFactory = sslEnabled ? getDefaultSslContextFactory() : null;
} else {
sslContextFactory = builder.sslConfig.createClientContextFactory();
@@ -210,8 +216,10 @@ public class Http2SolrClient extends SolrClient {
log.debug("Create Http2SolrClient with HTTP/1.1 transport");
... 138578 lines suppressed ...