vyatkinv commented on code in PR #4320:
URL: https://github.com/apache/solr/pull/4320#discussion_r3176928359
##########
solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/stream/TupleStream.java:
##########
@@ -213,14 +219,73 @@ public static List<String> getShards(
}
} else {
shards =
- getReplicas(zkHost, collection, streamContext,
requestParams).stream()
+ getReplicas(solrCloud, collection, streamContext,
requestParams).stream()
.map(Replica::getCoreUrl)
.collect(Collectors.toList());
}
return shards;
}
+ public static String getSolrCloud(
+ StreamFactory streamFactory, StreamExpression streamExpression, String
collectionName)
+ throws IOException {
+ var solrCloudExpression = streamFactory.getNamedOperand(streamExpression,
"solrCloud");
+ var zkHostExpression = streamFactory.getNamedOperand(streamExpression,
"zkHost");
+ String solrCloud = null;
+ if (zkHostExpression == null && solrCloudExpression == null) {
+ solrCloud = streamFactory.getCollectionZkHost(collectionName);
+ if (solrCloud == null) {
+ solrCloud = streamFactory.getDefaultZkHost();
+ }
+ } else if (solrCloudExpression != null
+ && solrCloudExpression.getParameter() instanceof StreamExpressionValue
exprValue) {
+ solrCloud = exprValue.getValue();
+ } else if (zkHostExpression != null
+ && zkHostExpression.getParameter() instanceof StreamExpressionValue
exprValue) {
+ solrCloud = exprValue.getValue();
+ }
+ if (solrCloud == null) {
+ throw new IOException(
+ String.format(
+ Locale.ROOT,
+ "invalid expression %s - solrCloud or zkHost not found for
collection '%s'",
+ streamExpression,
+ collectionName));
+ }
+ return solrCloud;
+ }
+
+ public static ModifiableSolrParams getModifiableSolrParamsWithExclusions(
+ List<StreamExpressionNamedParameter> namedParams, String... excluded) {
+ ModifiableSolrParams mParams = new ModifiableSolrParams();
+
+ Set<String> excludedSet = new HashSet<>(Arrays.asList(excluded));
+
+ for (StreamExpressionNamedParameter namedParam : namedParams) {
+ if (!excludedSet.contains(namedParam.getName())) {
+ mParams.add(namedParam.getName(),
namedParam.getParameter().toString().trim());
+ }
+ }
+
+ return mParams;
+ }
+
+ public static Map<String, String> getMapWithExclusions(
Review Comment:
done
I reworked streams that were using `getMapWithExclusions` to use
`SolrParams`, or `ModifiableSolrParams` where a mutable implementation is
required.
##########
solr/solrj-streaming/src/java/org/apache/solr/client/solrj/io/stream/UpdateStream.java:
##########
@@ -92,24 +91,28 @@ public UpdateStream(StreamExpression expression,
StreamFactory factory) throws I
streamExpressions.size()));
}
StreamExpression sourceStreamExpression = streamExpressions.get(0);
- init(collectionName, factory.constructStream(sourceStreamExpression),
zkHost, updateBatchSize);
+ init(
+ collectionName,
+ factory.constructStream(sourceStreamExpression),
+ solrCloud,
+ updateBatchSize);
}
public UpdateStream(
- String collectionName, TupleStream tupleSource, String zkHost, int
updateBatchSize)
+ String collectionName, TupleStream tupleSource, String solrCloud, int
updateBatchSize)
throws IOException {
if (updateBatchSize <= 0) {
throw new IOException(
String.format(Locale.ROOT, "batchSize '%d' must be greater than 0.",
updateBatchSize));
}
pruneVersionField = defaultPruneVersionField();
- init(collectionName, tupleSource, zkHost, updateBatchSize);
+ init(collectionName, tupleSource, solrCloud, updateBatchSize);
}
private void init(
- String collectionName, TupleStream tupleSource, String zkHost, int
updateBatchSize) {
+ String collectionName, TupleStream tupleSource, String solrCloud, int
updateBatchSize) {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]