[
https://issues.apache.org/jira/browse/NIFI-4583?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16299628#comment-16299628
]
ASF GitHub Bot commented on NIFI-4583:
--------------------------------------
Github user ijokarumawak commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2285#discussion_r158205010
--- Diff:
nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/SolrProcessor.java
---
@@ -205,47 +125,7 @@ public final void closeClient() {
* @return an HttpSolrClient or CloudSolrClient
*/
protected SolrClient createSolrClient(final ProcessContext context,
final String solrLocation) {
- final Integer socketTimeout =
context.getProperty(SOLR_SOCKET_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
- final Integer connectionTimeout =
context.getProperty(SOLR_CONNECTION_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
- final Integer maxConnections =
context.getProperty(SOLR_MAX_CONNECTIONS).asInteger();
- final Integer maxConnectionsPerHost =
context.getProperty(SOLR_MAX_CONNECTIONS_PER_HOST).asInteger();
- final SSLContextService sslContextService =
context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
- final String jaasClientAppName =
context.getProperty(JAAS_CLIENT_APP_NAME).getValue();
-
- final ModifiableSolrParams params = new ModifiableSolrParams();
- params.set(HttpClientUtil.PROP_SO_TIMEOUT, socketTimeout);
- params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT,
connectionTimeout);
- params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections);
- params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST,
maxConnectionsPerHost);
-
- // has to happen before the client is created below so that
correct configurer would be set if neeeded
- if (!StringUtils.isEmpty(jaasClientAppName)) {
- System.setProperty("solr.kerberos.jaas.appname",
jaasClientAppName);
- HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
- }
-
- final HttpClient httpClient = HttpClientUtil.createClient(params);
-
- if (sslContextService != null) {
- final SSLContext sslContext =
sslContextService.createSSLContext(SSLContextService.ClientAuth.REQUIRED);
- final SSLSocketFactory sslSocketFactory = new
SSLSocketFactory(sslContext);
- final Scheme httpsScheme = new Scheme("https", 443,
sslSocketFactory);
-
httpClient.getConnectionManager().getSchemeRegistry().register(httpsScheme);
- }
-
- if
(SOLR_TYPE_STANDARD.equals(context.getProperty(SOLR_TYPE).getValue())) {
- return new HttpSolrClient(solrLocation, httpClient);
- } else {
- final String collection =
context.getProperty(COLLECTION).evaluateAttributeExpressions().getValue();
- final Integer zkClientTimeout =
context.getProperty(ZK_CLIENT_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
- final Integer zkConnectionTimeout =
context.getProperty(ZK_CONNECTION_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
-
- CloudSolrClient cloudSolrClient = new
CloudSolrClient(solrLocation, httpClient);
- cloudSolrClient.setDefaultCollection(collection);
- cloudSolrClient.setZkClientTimeout(zkClientTimeout);
- cloudSolrClient.setZkConnectTimeout(zkConnectionTimeout);
- return cloudSolrClient;
- }
+ return SolrUtils.createSolrClient(context, solrLocation);
--- End diff --
About the static or non-static method for unit testing, this
createSolrClient method at SolrProcessor can be overridden at test case, so
SolrUtils can have everything as static. It looks good, sorry for the confusion.
> Restructure package nifi-solr-processors
> ----------------------------------------
>
> Key: NIFI-4583
> URL: https://issues.apache.org/jira/browse/NIFI-4583
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: Johannes Peter
> Assignee: Johannes Peter
> Priority: Minor
>
> Several functionalities currently implemented e. g. in GetSolr or
> SolrProcessor should be made available for other processors or controller
> services. A class SolrUtils should be created containing several static
> methods. This includes the methods
> - getRequestParams (PutSolrContentStream)
> - solrDocumentsToRecordSet (GetSolr)
> - createSolrClient (SolrProcessor)
> and the inner class QueryResponseOutputStreamCallback (GetSolr)
> Some unit tests might be affected.
> The method declaration
> protected SolrClient createSolrClient(final ProcessContext context, final
> String solrLocation)
> should be changed to
> public static SolrClient createSolrClient(final PropertyContext context,
> final String solrLocation)
> to be suitable also for controller services.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)