You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@solr.apache.org by Keerthi Turakapalli <tk...@opentext.com.INVALID> on 2022/12/20 10:03:17 UTC

Creation of CloudSolrClient with httpClient is faling

Hi,

Teamsite product uses solr from version 7.x and has been upgrading to version 8.11.2 with no issues. However, when we tried to upgrade to solr 9, we are seeing many issues with compilation due to package structure changes/class removals/internal method implementation changes, etc.
We changed our configuration files and made code changes to fix these compilation issues but facing issues with the below code change.

Teamsite code using solr:


builder = new CloudSolrClient
        .Builder(Collections.singletonList(mServerDetails.getZookeeperUrl()), Optional.empty())
        .withHttpClient(getSecureClient());

private CloseableHttpClient getSecureClient() {
    CloseableHttpClient cHttpClient = null;
    try {
        TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
        SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
        SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new DefaultHostnameVerifier());
        Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create().
                                                                  register(SCHEMA_HTTPS, sslConnectionSocketFactory).build();
        BasicHttpClientConnectionManager connectionManager = new BasicHttpClientConnectionManager(socketFactoryRegistry);
        cHttpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory).setConnectionManager(connectionManager).build();
    } catch(NoSuchAlgorithmException | KeyStoreException | KeyManagementException ex)
    {
        mLogger.atError().log("Processing httpclient failed.: {}", ex);
    }
    return cHttpClient;

Here while building solrCloudClient withHttpClient method was accepting the httpClient type parameter till now. However, the solr9 withHttpClient method accepts the Http2SolrClient type parameter.  The local build compilation is failing because of this typecast issue.
We tried to find an alternative code fix for this by trying many approaches but did not work. Could you please provide an alternative approach for this?

Also,
Teamsite implementation:

ZkClientClusterStateProvider zkClusterClient = new ZkClientClusterStateProvider(zookeeperURL);
try{
       zkClusterClient.uploadConfig(configFolder.toPath(), configName);
}

This was also throwing issue because of the method implementation change, So I changed the code like below,


SolrZkClient zkClient = new SolrZkClient(zookeeperURL, 300);
ZkConfigSetService zkConfigSet = new ZkConfigSetService(zkClient);

try

{
    zkConfigSet.uploadConfig(configName, configFolder.toPath());

}

Please let me know if this usage is valid, if not please let me know the alternative for this as well.


Thanks & Regards,
​Keerthi Turakapalli


Re: Creation of CloudSolrClient with httpClient is faling

Posted by David Smiley <ds...@apache.org>.
Hello,

From the Solr 9 upgrade notes:

> The old CloudSolrClient has been renamed as CloudLegacySolrClient and
> deprecated
>

So you could continue to use the client you used to use, now called
CloudLegacySolrClient (based on Apache HttpClient), if you wish.  The Jetty
HttpClient based CloudSolrClient now holds the name that the former one
had.  I wish this was more explicitly declared in the notes.  Preferably,
you'd see how Jetty's HttpClient works to accomplish the same as you were
doing with Apache's HttpClient.

~ David Smiley
Apache Lucene/Solr Search Developer
http://www.linkedin.com/in/davidwsmiley


On Tue, Dec 20, 2022 at 9:51 AM Keerthi Turakapalli
<tk...@opentext.com.invalid> wrote:

> Hi,
>
> Teamsite product uses solr from version 7.x and has been upgrading to
> version 8.11.2 with no issues. However, when we tried to upgrade to solr 9,
> we are seeing many issues with compilation due to package structure
> changes/class removals/internal method implementation changes, etc.
> We changed our configuration files and made code changes to fix these
> compilation issues but facing issues with the below code change.
>
> Teamsite code using solr:
>
>
> builder = new CloudSolrClient
>
> .Builder(Collections.singletonList(mServerDetails.getZookeeperUrl()),
> Optional.empty())
>         .withHttpClient(getSecureClient());
>
> private CloseableHttpClient getSecureClient() {
>     CloseableHttpClient cHttpClient = null;
>     try {
>         TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
>         SSLContext sslContext =
> SSLContexts.custom().loadTrustMaterial(null,
> acceptingTrustStrategy).build();
>         SSLConnectionSocketFactory sslConnectionSocketFactory = new
> SSLConnectionSocketFactory(sslContext, new DefaultHostnameVerifier());
>         Registry<ConnectionSocketFactory> socketFactoryRegistry =
> RegistryBuilder.<ConnectionSocketFactory>create().
>
> register(SCHEMA_HTTPS, sslConnectionSocketFactory).build();
>         BasicHttpClientConnectionManager connectionManager = new
> BasicHttpClientConnectionManager(socketFactoryRegistry);
>         cHttpClient =
> HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory).setConnectionManager(connectionManager).build();
>     } catch(NoSuchAlgorithmException | KeyStoreException |
> KeyManagementException ex)
>     {
>         mLogger.atError().log("Processing httpclient failed.: {}", ex);
>     }
>     return cHttpClient;
>
> Here while building solrCloudClient withHttpClient method was accepting
> the httpClient type parameter till now. However, the solr9 withHttpClient
> method accepts the Http2SolrClient type parameter.  The local build
> compilation is failing because of this typecast issue.
> We tried to find an alternative code fix for this by trying many
> approaches but did not work. Could you please provide an alternative
> approach for this?
>
> Also,
> Teamsite implementation:
>
> ZkClientClusterStateProvider zkClusterClient = new
> ZkClientClusterStateProvider(zookeeperURL);
> try{
>        zkClusterClient.uploadConfig(configFolder.toPath(), configName);
> }
>
> This was also throwing issue because of the method implementation change,
> So I changed the code like below,
>
>
> SolrZkClient zkClient = new SolrZkClient(zookeeperURL, 300);
> ZkConfigSetService zkConfigSet = new ZkConfigSetService(zkClient);
>
> try
>
> {
>     zkConfigSet.uploadConfig(configName, configFolder.toPath());
>
> }
>
> Please let me know if this usage is valid, if not please let me know the
> alternative for this as well.
>
>
> Thanks & Regards,
> ​Keerthi Turakapalli
>
>