CloudSolrClient线程安全吗?

时间:2017-03-09 16:19:07

标签: java solrj

我正在尝试在多线程环境中使用CloudSolrClient实例。 CloudSolrClient类是线程安全的吗?还是应该作为数据库连接池进行管理?

任何建议都会有很大帮助。

由于

1 个答案:

答案 0 :(得分:1)

是的,CloudSolrClient是线程安全的,您可以在所有线程之间共享已配置的单例。

只有少数precautions

  如果您要求,

C:\Users\pbreach\Continuum\Anaconda3\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 53720 --file C:/Users/pbreach/Dropbox/FIDS/cci/bluebook/code/input.py Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 2, in <module> from _pydevd_bundle.pydevd_cython import trace_dispatch, PyDBAdditionalThreadInfo ModuleNotFoundError: No module named '_pydevd_bundle.pydevd_cython' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevconsole.py", line 8, in <module> from code import InteractiveConsole ImportError: cannot import name 'InteractiveConsole' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevd.py", line 26, in <module> from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_additional_thread_info.py", line 17, in <module> from _pydevd_bundle.pydevd_cython_wrapper import PyDBAdditionalThreadInfo File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 26, in <module> mod = __import__(check_name) File "_pydevd_bundle\pydevd_cython_win32_36_64.pyx", line 9, in init _pydevd_bundle.pydevd_cython_win32_36_64 (_pydevd_bundle/pydevd_cython_win32_36_64.c:21388) File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_frame.py", line 10, in <module> from _pydevd_bundle.pydevd_breakpoints import get_exception_breakpoint File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_breakpoints.py", line 15, in <module> from _pydevd_bundle.pydevd_comm import get_global_debugger File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 75, in <module> import pydevconsole File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevconsole.py", line 10, in <module> from _pydevd_bundle.pydevconsole_code_for_ironpython import InteractiveConsole File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\_pydevd_bundle\pydevconsole_code_for_ironpython.py", line 105 except SyntaxError, err: ^ SyntaxError: invalid syntax Process finished with exit code 1 不是线程安全的   多个集合,因为CloudSolrClient是可变的。这个可以   如果你试图从a索引到多个集合,那就太痛苦了   单个文件队列。

但是您可以拥有多个defaultCollection个实例,每个实例都为每个集合配置一个。