solrcloud dead-lock

2016-07-02 Thread Kent Mu
Hi friends

I came across a problem when use solrcloud, it is dead-lock. The version is
4.9.0.

we got the java core log, it looks like the http connection pool is
exhausted and most threads are waiting to get a free connection.

I have increased http connection defaults for the SolrJ client, and also
configed the connection defaults in solr.xml for all shard servers as below.



6
3
1
500


*the java stack as below*

"httpShardExecutor-3-thread-541" prio=10 tid=0x7f7b1c02b000 nid=0x20af
waiting on condition [0x7f79fd49]
   java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for  <0x000605710068> (a
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at org.apache.http.pool.PoolEntryFuture.await(PoolEntryFuture.java:133)
at
org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:282)
at
org.apache.http.pool.AbstractConnPool.access$000(AbstractConnPool.java:64)
at
org.apache.http.pool.AbstractConnPool$2.getPoolEntry(AbstractConnPool.java:177)
at
org.apache.http.pool.AbstractConnPool$2.getPoolEntry(AbstractConnPool.java:170)
at org.apache.http.pool.PoolEntryFuture.get(PoolEntryFuture.java:102)
at
org.apache.http.impl.conn.PoolingClientConnectionManager.leaseConnection(PoolingClientConnectionManager.java:208)
at
org.apache.http.impl.conn.PoolingClientConnectionManager$1.getConnection(PoolingClientConnectionManager.java:195)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:422)
at
org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:452)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206)
at
org.apache.solr.client.solrj.impl.LBHttpSolrServer.doRequest(LBHttpSolrServer.java:340)
at
org.apache.solr.client.solrj.impl.LBHttpSolrServer.request(LBHttpSolrServer.java:301)
at
org.apache.solr.handler.component.HttpShardHandlerFactory.makeLoadBalancedRequest(HttpShardHandlerFactory.java:205)
at
org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:162)
at
org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:119)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

*please help me, look forward to your reply. Thanks a lot!*

Best Regards!
Kent


solrcloud goes down

2016-07-02 Thread Kent Mu
Hi all

I came across a problem when use solrcloud, it goes down. The version is
4.9.0.

we got the java core log, it looks like the http connection pool is
exhausted and most threads are waiting to get a free connection.

I have increased http connection defaults for the SolrJ client, and also
configed the connection defaults in solr.xml for all shard servers as below.



6
3
1
500


*the java stack as below*

"httpShardExecutor-3-thread-541" prio=10 tid=0x7f7b1c02b000 nid=0x20af
waiting on condition [0x7f79fd49]
   java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for  <0x000605710068> (a
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at org.apache.http.pool.PoolEntryFuture.await(PoolEntryFuture.java:133)
at
org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:282)
at
org.apache.http.pool.AbstractConnPool.access$000(AbstractConnPool.java:64)
at
org.apache.http.pool.AbstractConnPool$2.getPoolEntry(AbstractConnPool.java:177)
at
org.apache.http.pool.AbstractConnPool$2.getPoolEntry(AbstractConnPool.java:170)
at org.apache.http.pool.PoolEntryFuture.get(PoolEntryFuture.java:102)
at
org.apache.http.impl.conn.PoolingClientConnectionManager.leaseConnection(PoolingClientConnectionManager.java:208)
at
org.apache.http.impl.conn.PoolingClientConnectionManager$1.getConnection(PoolingClientConnectionManager.java:195)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:422)
at
org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:452)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206)
at
org.apache.solr.client.solrj.impl.LBHttpSolrServer.doRequest(LBHttpSolrServer.java:340)
at
org.apache.solr.client.solrj.impl.LBHttpSolrServer.request(LBHttpSolrServer.java:301)
at
org.apache.solr.handler.component.HttpShardHandlerFactory.makeLoadBalancedRequest(HttpShardHandlerFactory.java:205)
at
org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:162)
at
org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:119)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

*please help me, look forward to your reply. Thanks a lot!*


Best Regards!
Kent


Re: Data import handler in techproducts example

2016-07-02 Thread Ahmet Arslan
Hi Jonas,

Search for the 
solr-dataimporthandler-*.jar place it under a lib directory (same level as the 
solr.xml file) along with the mysql jdbc driver (mysql-connector-java-*.jar)

Please see:
https://cwiki.apache.org/confluence/display/solr/Lib+Directives+in+SolrConfig




On Saturday, July 2, 2016 9:56 PM, Jonas Vasiliauskas 
 wrote:
Hey,

I'm quite new to solr and java environments. I have a goal for myself to 
import some data from mysql database in techproducts (core) example.

I have setup data import handler (DIH) for techproducts based on 
instructions here https://wiki.apache.org/solr/DIHQuickStart , but looks 
like solr doesn't load DIH libraries, could someone please explain in 
quick words on how to check if DIH is loaded and if not - how can I load 
it ?

Stacktrace is here: http://pastebin.ca/3654347

Thanks,


Data import handler in techproducts example

2016-07-02 Thread Jonas Vasiliauskas

Hey,

I'm quite new to solr and java environments. I have a goal for myself to 
import some data from mysql database in techproducts (core) example.


I have setup data import handler (DIH) for techproducts based on 
instructions here https://wiki.apache.org/solr/DIHQuickStart , but looks 
like solr doesn't load DIH libraries, could someone please explain in 
quick words on how to check if DIH is loaded and if not - how can I load 
it ?


Stacktrace is here: http://pastebin.ca/3654347

Thanks,


Data import handler in techproducts example

2016-07-02 Thread Jonas Vasiliauskas

Hey,

I'm quite new to solr and java environments. I have a goal for myself to 
import some data from mysql database in techproducts (core) example.


I have setup data import handler (DIH) for techproducts based on 
instructions here https://wiki.apache.org/solr/DIHQuickStart , but looks 
like solr doesn't load DIH libraries, could someone please explain in 
quick words on how to check if DIH is loaded and if not - how can I load 
it ?


Stacktrace is here: http://pastebin.ca/3654347

Thanks,


Re: an advice: why not to add a searching model for mailing list

2016-07-02 Thread Ahmet Arslan
Hi Kent,


There are already two search systems for the task:
http://find.searchhub.org
http://search-lucene.com

Is this what you mean by saying 'search model'?
Ahmet



On Saturday, July 2, 2016 6:43 PM, Kent Mu  wrote:



hi all,
I wonder why not do add a searching model for mailing list, so that we can
filter and query the usage info by searching the specified words quickly.

Best Regards!
Kent


an advice: why not to add a searching model for mailing list

2016-07-02 Thread Kent Mu
hi all,
 I wonder why not do add a searching model for mailing list, so that we can
filter and query the usage info by searching the specified words quickly.

Best Regards!
Kent


Re: questions for the method "shutdown" of CloudSolrServer

2016-07-02 Thread Kent Mu
Thanks a lot!
I see now. still have a thorny problem about solrcloud. please do me a
favor to analysis it.

I came across a problem when use solrcloud , it goes down, not an OOM
issue. The version is 4.9.0.

we got the java core log, it looks like the http connection pool is
exhausted and most threads are waiting to get a free connection.

I have increased http connection defaults for the SolrJ client, and also
configed the connection defaults in *solr.xml* for all shard servers as
below.


6
3
1
500


*the java stack as below *

"httpShardExecutor-3-thread-541" prio=10 tid=0x7f7b1c02b000 nid=0x20af
waiting on condition [0x7f79fd49]
   java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for  <0x000605710068> (a
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at
java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at org.apache.http.pool.PoolEntryFuture.await(PoolEntryFuture.java:133)
at
org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:282)
at
org.apache.http.pool.AbstractConnPool.access$000(AbstractConnPool.java:64)
at
org.apache.http.pool.AbstractConnPool$2.getPoolEntry(AbstractConnPool.java:177)
at
org.apache.http.pool.AbstractConnPool$2.getPoolEntry(AbstractConnPool.java:170)
at org.apache.http.pool.PoolEntryFuture.get(PoolEntryFuture.java:102)
at
org.apache.http.impl.conn.PoolingClientConnectionManager.leaseConnection(PoolingClientConnectionManager.java:208)
at
org.apache.http.impl.conn.PoolingClientConnectionManager$1.getConnection(PoolingClientConnectionManager.java:195)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:422)
at
org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.executeMethod(HttpSolrServer.java:452)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:210)
at
org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:206)
at
org.apache.solr.client.solrj.impl.LBHttpSolrServer.doRequest(LBHttpSolrServer.java:340)
at
org.apache.solr.client.solrj.impl.LBHttpSolrServer.request(LBHttpSolrServer.java:301)
at
org.apache.solr.handler.component.HttpShardHandlerFactory.makeLoadBalancedRequest(HttpShardHandlerFactory.java:205)
at
org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:162)
at
org.apache.solr.handler.component.HttpShardHandler$1.call(HttpShardHandler.java:119)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

besides, we use the singleton pattern to create and get the CloudSolrServer
connection.

Best Regards!
Kent

2016-07-02 20:40 GMT+08:00 Shawn Heisey :

> On 7/2/2016 2:29 AM, Kent Mu wrote:
> > this kind of method by create an instance with a LBHttpSolrServer does
> > not need to release LBHttpSolrServer and HttpClient??
>
> The cloud client will only shutdown the LB client and its HttpClient if
> it was the one who created those resources.  When they are created
> external to the cloud client, the cloud client cannot assume that it is
> the only thing using them.
>
> Thanks,
> Shawn
>
>


Re: questions for the method "shutdown" of CloudSolrServer

2016-07-02 Thread Shawn Heisey
On 7/2/2016 2:29 AM, Kent Mu wrote:
> this kind of method by create an instance with a LBHttpSolrServer does
> not need to release LBHttpSolrServer and HttpClient?? 

The cloud client will only shutdown the LB client and its HttpClient if
it was the one who created those resources.  When they are created
external to the cloud client, the cloud client cannot assume that it is
the only thing using them.

Thanks,
Shawn



Re: Load a java class on start up

2016-07-02 Thread Mark Robinson
Yes.
Integrating my CustomComponent along with SolrCoreAware (I was unaware of
this prev) should give me what I am looking for.

Thanks!
Mark.

On Sat, Jul 2, 2016 at 5:57 AM, Andrea Gazzarini  wrote:

> You're welcome ;) is that close to what you were looking for?
> On 2 Jul 2016 11:53, "Mark Robinson"  wrote:
>
> > Thanks much Andrea esp. for the suggestion of SolrCoreAware!
> >
> >
> >
> > Best,
> > Mark.
> >
> > On Thu, Jun 30, 2016 at 10:23 AM, Andrea Gazzarini 
> > wrote:
> >
> > > Hi,
> > > the lifecycle of your Solr extension (i.e. the component) is not
> > something
> > > that's up to you.
> > > Before designing the component you should read the framework docs [1],
> in
> > > order to understand the context where it will live, once deployed.
> > >
> > > There's nothing, as far as I know, other than the component callbacks
> > > (e.g. the inform, init methods) that can help you to manage the
> lifecycle
> > > of a custom class you're using within the component. Look at the
> > > SolrCoreAware [2] interface, maybe it could fit your needs.
> > > From what you write it seems you could need something like a singleton
> > > (which is often an anti-pattern in distributed environment) , but
> without
> > > further details I'm just shooting in the dark
> > >
> > > In addition: you wrote a component so I guess it shouldn't be so hard
> to
> > > have a look at one of the existing built-in components. I'm quite sure
> > they
> > > already met (and solved) a similar issue.
> > >
> > > Best,
> > > Andrea
> > >
> > > [1]
> > >
> >
> https://lucene.apache.org/solr/6_1_0/solr-core/org/apache/solr/handler/component/SearchComponent.html
> > > [2] https://wiki.apache.org/solr/SolrPlugins#SolrCoreAware
> > >
> > >
> > > On 30/06/16 16:00, Mark Robinson wrote:
> > >
> > >> Hi,
> > >>
> > >> I have a java OBJECT which I need to load once.
> > >> I have written a java custom component, which I have added in
> > >> "last-components" in solrconfig.xml, from which I want to access the
> > above
> > >> mentioned OBJECT when each search request comes in.
> > >>
> > >> Is there a way I can load a java object on server/ instance startup?
> > >> OR
> > >> Load it when the first call comes to SOLR?
> > >>
> > >> For the time being I created that Java object inside the custom
> > component
> > >> itself; but it is loaded each time a search request comes in.
> > >>
> > >> Could some one pls give some pointers on how my above requirement can
> be
> > >> achieved in SOLR?
> > >>
> > >> Thanks!
> > >> Mark
> > >>
> > >>
> > >
> >
>


Re: Load a java class on start up

2016-07-02 Thread Andrea Gazzarini
You're welcome ;) is that close to what you were looking for?
On 2 Jul 2016 11:53, "Mark Robinson"  wrote:

> Thanks much Andrea esp. for the suggestion of SolrCoreAware!
>
>
>
> Best,
> Mark.
>
> On Thu, Jun 30, 2016 at 10:23 AM, Andrea Gazzarini 
> wrote:
>
> > Hi,
> > the lifecycle of your Solr extension (i.e. the component) is not
> something
> > that's up to you.
> > Before designing the component you should read the framework docs [1], in
> > order to understand the context where it will live, once deployed.
> >
> > There's nothing, as far as I know, other than the component callbacks
> > (e.g. the inform, init methods) that can help you to manage the lifecycle
> > of a custom class you're using within the component. Look at the
> > SolrCoreAware [2] interface, maybe it could fit your needs.
> > From what you write it seems you could need something like a singleton
> > (which is often an anti-pattern in distributed environment) , but without
> > further details I'm just shooting in the dark
> >
> > In addition: you wrote a component so I guess it shouldn't be so hard to
> > have a look at one of the existing built-in components. I'm quite sure
> they
> > already met (and solved) a similar issue.
> >
> > Best,
> > Andrea
> >
> > [1]
> >
> https://lucene.apache.org/solr/6_1_0/solr-core/org/apache/solr/handler/component/SearchComponent.html
> > [2] https://wiki.apache.org/solr/SolrPlugins#SolrCoreAware
> >
> >
> > On 30/06/16 16:00, Mark Robinson wrote:
> >
> >> Hi,
> >>
> >> I have a java OBJECT which I need to load once.
> >> I have written a java custom component, which I have added in
> >> "last-components" in solrconfig.xml, from which I want to access the
> above
> >> mentioned OBJECT when each search request comes in.
> >>
> >> Is there a way I can load a java object on server/ instance startup?
> >> OR
> >> Load it when the first call comes to SOLR?
> >>
> >> For the time being I created that Java object inside the custom
> component
> >> itself; but it is loaded each time a search request comes in.
> >>
> >> Could some one pls give some pointers on how my above requirement can be
> >> achieved in SOLR?
> >>
> >> Thanks!
> >> Mark
> >>
> >>
> >
>


Re: Load a java class on start up

2016-07-02 Thread Mark Robinson
Thanks much Andrea esp. for the suggestion of SolrCoreAware!



Best,
Mark.

On Thu, Jun 30, 2016 at 10:23 AM, Andrea Gazzarini  wrote:

> Hi,
> the lifecycle of your Solr extension (i.e. the component) is not something
> that's up to you.
> Before designing the component you should read the framework docs [1], in
> order to understand the context where it will live, once deployed.
>
> There's nothing, as far as I know, other than the component callbacks
> (e.g. the inform, init methods) that can help you to manage the lifecycle
> of a custom class you're using within the component. Look at the
> SolrCoreAware [2] interface, maybe it could fit your needs.
> From what you write it seems you could need something like a singleton
> (which is often an anti-pattern in distributed environment) , but without
> further details I'm just shooting in the dark
>
> In addition: you wrote a component so I guess it shouldn't be so hard to
> have a look at one of the existing built-in components. I'm quite sure they
> already met (and solved) a similar issue.
>
> Best,
> Andrea
>
> [1]
> https://lucene.apache.org/solr/6_1_0/solr-core/org/apache/solr/handler/component/SearchComponent.html
> [2] https://wiki.apache.org/solr/SolrPlugins#SolrCoreAware
>
>
> On 30/06/16 16:00, Mark Robinson wrote:
>
>> Hi,
>>
>> I have a java OBJECT which I need to load once.
>> I have written a java custom component, which I have added in
>> "last-components" in solrconfig.xml, from which I want to access the above
>> mentioned OBJECT when each search request comes in.
>>
>> Is there a way I can load a java object on server/ instance startup?
>> OR
>> Load it when the first call comes to SOLR?
>>
>> For the time being I created that Java object inside the custom component
>> itself; but it is loaded each time a search request comes in.
>>
>> Could some one pls give some pointers on how my above requirement can be
>> achieved in SOLR?
>>
>> Thanks!
>> Mark
>>
>>
>


questions for the method "shutdown" of CloudSolrServer

2016-07-02 Thread Kent Mu
hi all,

I create a CloudSolrServer Connection by singleton pattern like this

public synchronized static CloudSolrServer getSolrCloudReadServer() {
if (reviewSolrCloudServer == null) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 1);
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 500);
HttpClient client = HttpClientUtil.createClient(params);
LBHttpSolrServer lbServer = new LBHttpSolrServer(client);

lbServer.setConnectionTimeout(ReviewProperties.getCloudConnectionTimeOut());
lbServer.setSoTimeout(ReviewProperties.getCloudSoTimeOut());

reviewSolrCloudServer = new
CloudSolrServer(ReviewProperties.getZkHost(),lbServer);
reviewSolrCloudServer.setDefaultCollection("commodityReview");

reviewSolrCloudServer.setZkClientTimeout(ReviewProperties.getZkClientTimeout());

reviewSolrCloudServer.setZkConnectTimeout(ReviewProperties.getZkConnectTimeout());
reviewSolrCloudServer.connect();
}
return reviewSolrCloudServer;
}

and I see the solrj API, the method to create an instance, and the method
of shutdown

  public CloudSolrServer(String zkHost, LBHttpSolrServer lbServer) {
this.zkHost = zkHost;
this.lbServer = lbServer;
this.updatesToLeaders = true;
shutdownLBHttpSolrServer = false;
  }

  public void shutdown() {
if (zkStateReader != null) {
  synchronized(this) {
if (zkStateReader!= null)
  zkStateReader.close();
zkStateReader = null;
  }
}

if (shutdownLBHttpSolrServer) {
  lbServer.shutdown();
}

if (myClient!=null) {
  myClient.getConnectionManager().shutdown();
}

if(this.threadPool != null && !this.threadPool.isShutdown()) {
  this.threadPool.shutdown();
}
  }

this kind of method by create an instance with a LBHttpSolrServer does not
need to release LBHttpSolrServer  and HttpClient??

look forward to your reply!

Best Regards!
Kent Mu


Re: solr shutdown error

2016-07-02 Thread Kent Mu
Thanks for your reply!

I do understand your explaination, but another question accurs, When I
create CloudSolrServer Connection by singleton pattern like this, and I
call shutdown, but it's OK. the solr version is 4.9.0. that's why?

public synchronized static CloudSolrServer getSolrCloudReadServer() {
if (reviewSolrCloudServer == null) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 1);
params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 500);
HttpClient client = HttpClientUtil.createClient(params);
LBHttpSolrServer lbServer = new LBHttpSolrServer(client);

lbServer.setConnectionTimeout(ReviewProperties.getCloudConnectionTimeOut());
lbServer.setSoTimeout(ReviewProperties.getCloudSoTimeOut());

reviewSolrCloudServer = new
CloudSolrServer(ReviewProperties.getZkHost(),lbServer);
reviewSolrCloudServer.setDefaultCollection("commodityReview");

reviewSolrCloudServer.setZkClientTimeout(ReviewProperties.getZkClientTimeout());

reviewSolrCloudServer.setZkConnectTimeout(ReviewProperties.getZkConnectTimeout());
reviewSolrCloudServer.connect();
}
return reviewSolrCloudServer;
}


2016-07-02 14:22 GMT+08:00 Shawn Heisey :

> On 7/1/2016 10:59 PM, Kent Mu wrote:
> > solr version: 4.9.0 I create and get a HttpSolrServer connection by
> > singleton pattern. I find the method of "shutdown" in solrj API, so I
> > decided to use "shutdown" to release resources, but I got the error as
> > below, It is due to singleton pattern?
>
> If you call shutdown, that client object can no longer be used.  You
> will need to make a new one.
>
> The expected usage pattern for the client object is that you will create
> one object when the program starts and use it for all threads until the
> program exits.  Whether or not to use the singleton pattern for that is
> up to you.  Usually the only time you would call shutdown is just before
> program exit ... but if the program is exiting, shutdown isn't really
> necessary.
>
> If you are in a situation where client objects are being regularly
> created, then you would want to do shutdown on each of them when you are
> finished so you don't have a resource leak.  Creating many client
> objects is not recommended.
>
> Thanks,
> Shawn
>
>