[ 
https://issues.apache.org/jira/browse/SOLR-6894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14262648#comment-14262648
 ] 

Alan Woodward commented on SOLR-6894:
-------------------------------------

I've rethought this slightly, what I want to do now is introduce another 
abstraction, SolrNodeClient, which extends SolrClient and adds two methods:
* SolrClient forCore(String core)
* SolrClient forCollection(String collection)

HttpSolrClient and CloudSolrClient both extend SolrNodeClient.  You create a 
SolrNodeClient to point at a particular node (or zk-discovered cluster, in the 
case of CloudSolrClient), which you can then use for admin requests.  If you 
want to execute requests against a particular collection, call 
#forCollection(String collection), and you get a specialised SolrClient that 
shares its resources (HttpClient, ZkClient, etc) with the parent 
SolrNodeClient.  Calling #forCore() on an HttpSolrClient has the same effect as 
calling #forCollection(), but on a CloudSolrClient it will return a client that 
talks to a specific core in the cluster, with a default parameter of 
distrib=false, which is useful for debugging.

This means that your API when communicating with an empty node would be 
something like:
{code}
SolrNodeClient client = new HttpSolrClient(pathToMultiCoreServer);

CoreAdminRequest.Create createReq = new Create();
createReq.setCoreName("myCore");
createReq.setConfigSet("myConfigSet");
client.request(createReq);

SolrClient myCoreClient = client.forCore("myCore")
{code}

and for SolrCloud:

{code}
CloudSolrClient clusterClient = new CloudSolrClient(zkPath);

CollectionAdminRequest.Create createReq = new CollectionAdminRequest.Create();
createReq.setName("myCollection")
createReq.setConfig("myConfig")
clusterClient.execute(createReq);

SolrClient collectionClient = client.forCollection("myCollection");
{code}

> Add MultiCoreSolrServer 
> ------------------------
>
>                 Key: SOLR-6894
>                 URL: https://issues.apache.org/jira/browse/SOLR-6894
>             Project: Solr
>          Issue Type: New Feature
>          Components: SolrJ
>    Affects Versions: 5.0, Trunk
>            Reporter: Alan Woodward
>            Assignee: Alan Woodward
>            Priority: Minor
>         Attachments: SOLR-6894.patch
>
>
> At the moment, it isn't possible to use a single SolrServer instance to 
> create new cores via CoreAdmin on an empty node, and then query those nodes.  
> MultiCoreSolrServer is a utility class that does just that, by allowing you 
> to create child SolrServer instances for individual cores that share the 
> underlying HttpClient.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to