`

backup-s-server

阅读更多

public class SolrClientFactory {

 

private static Map<String, SolrClient> SERVERS = new ConcurrentHashMap<String, SolrClient>();

 

/**

* Get a solrClient by a specified core/collection name

* @param coreName

* @return a SolrClient

*/

public static SolrClient getSolrClient(String coreName)

{

if(StringUtils.isBlank(coreName))

{

log.error("Failed to get available core name:"+coreName);

throw new SolrServerException("No found out any solr server for a EMPTY core/collection name.");

}

 

SolrClient solrClient = null;

if(!SERVERS.containsKey(coreName))

{

solrClient = SolrClientSingleton.getSolrClientInstance(coreName);

SERVERS.put(coreName, solrClient);

}

else

{

solrClient = SERVERS.get(coreName);

}

 

if(solrClient == null)

{

log.error("No found any solr server for a specified core/collection name:"+coreName);

throw new SolrServerException("No found any solr server for a specified core/collection name:"+coreName);

}

 

return solrClient;

}

}

 

 

public class SolrClientSingleton

{

 

private static ISolrConfiguration config = new SolrConfiguration();

 

private SolrClientSingleton() {}

 

private static class SingletonHolder 

{  

private static final SolrClientSingleton INSTANCE = new SolrClientSingleton();  

}  

 

/**

* Get HttpSolrClient for a single node mode

* @returnSolrClient

*/

public static SolrClient getSolrClientInstance(String coreName)

{

return SingletonHolder.INSTANCE.createSolrClient(coreName); 

}

 

 

private SolrClient createSolrClient(String coreName) 

{

try

{

if(config.isCloudMode())

{

CloudSolrClient cloudSolrClient = new CloudSolrClient(config.getZkHosts());

cloudSolrClient.setDefaultCollection(coreName);

cloudSolrClient.connect();

cloudSolrClient.setZkConnectTimeout(config.getZkConnectionTimeout());

cloudSolrClient.setZkClientTimeout(config.getZkClientTimeout());

return cloudSolrClient;

}

else

{

 

HttpSolrClient httpSolrClient = new HttpSolrClient(getSolrURL(config.getUrl(),coreName));

httpSolrClient.setConnectionTimeout(config.getConnectionTimeout());

httpSolrClient.setDefaultMaxConnectionsPerHost(config.getMaxConnectionsPerHost());

httpSolrClient.setMaxTotalConnections(config.getMaxTotalConnections());

 

return httpSolrClient;

}

}

catch(Exception e)

{

log.error("Failed to connect to the solr server due to:"+e.toString());

throw new SolrServerException("Failed to connect to the solr server.");

}

}

 

/**

* Get a String of which is combined by Solr server url  and core name

* @param url

* @param coreName

* @return a url string

*/

private String getSolrURL(String url,String coreName)

{

if(StringUtils.isBlank(url) )

{

log.error("Solr url cannot be EMPTY.");

return null;

}

 

StringBuilder sb = new StringBuilder(url);

if(!url.endsWith("/"))

{

sb.append("/");

}

 

if(!StringUtils.isBlank(coreName))

{

sb.append(coreName);

}

 

return sb.toString();

}

}

分享到:
评论

相关推荐

    SQL Server自动备份脚本 bat

    sqlcmd -S YourServerName -U YourUsername -P YourPassword -d YourDatabaseName -Q "EXEC dbo.YourBackupProcedure" ``` 3. **设置Windows计划任务**:在Windows操作系统中,通过“任务计划程序”设置一个计划,让...

    snebu:简单的网络加密备份实用程序

    介绍Snebu-简单的网络备份实用程序,名义上的系统,一切都已备份Snebu是一种高效,增量,快照式,重复数据删除,压缩,加密,数据库支持,多主机,...server central-backup-server -k myhost.key \ -k corporate-s

    Microsoft SQL Server 2016: A Beginner’s Guide, 6th Edition

    http://finelybook.com/microsoft-sql-server-2016-a-beginners-guide-6th-edition/ Book Description to Finelybook sorting Up-to-date Microsoft SQL Server 2016 skills made easy! Get up and running on ...

    爱数AnyBackup 备份软件-备份一体机产品介绍.pdf

    此外,它还能与多种数据库系统(如Oracle、SQL Server、MySQL等)以及邮件系统(如Outlook Express、Thunderbird)配合,确保各类应用的数据安全。 在处理大数据增长方面,AnyBackup采用了一系列先进技术,如第三代...

    PowerShell_Restore-BackupDatabaseUsingBakFiles_sqlserver_windows

    描述中的"this script it's just to create a backup or restore your database."暗示了该脚本会涵盖这两个关键功能。备份部分可能涉及获取数据库信息,选择备份类型,设置备份位置,然后调用`Backup-DbaDatabase` ...

    SQLServer导出带数据的脚本

    sqlcmd -S 服务器名称 -d 数据库名称 -Q "BACKUP DATABASE 数据库名称 TO DISK = '文件路径'" ``` 四、导出结果 ---------------- 无论使用 SSMS 还是 sqlcmd,导出带数据的脚本都可以用于恢复和部署数据库结构和...

    lenovo backup exec 操作手册

    文档中提到的“ BackupExec20.1 Administrator's Guide”指的是管理员指南,这是操作手册的一个组成部分,涵盖了Backup Exec的管理员所需了解的详细信息。管理员指南中介绍了Backup Exec的基本信息、工作原理、安装...

    magent-0.6-修正版

    -b ip:port, set backup memcached server ip and port -l ip, local bind ip address, default is 0.0.0.0 -n number, set max connections, default is 4096 -D don't go to background -k use ketama key ...

    SQLServer2008自动备份脚本

    在SQL Server 2008中,为了确保数据的安全性和防止意外丢失,设置自动备份是一项至关重要的任务。这里我们将详细探讨如何使用SQL Server自带的`sqlcmd`工具以及如何创建一个自定义的备份脚本来实现这一功能。 首先...

    sql server 2005导出sql文件工具

    sqlcmd -S &lt;server_name&gt; -U &lt;username&gt; -P &lt;password&gt; -Q "RESTORE DATABASE &lt;database_name&gt; FROM DISK='&lt;backup_file&gt;' WITH REPLACE" ``` 这里的 `&lt;backup_file&gt;` 是数据库备份文件的路径。 总结来说,SQL ...

    wget-1.11.4-1

    -S, --server-response print server response. --spider don't download anything. -T, --timeout=SECONDS set all timeout values to SECONDS. --dns-timeout=SECS set the DNS lookup timeout to SECS. --...

    magent-0.5-修正版

    -b ip:port, set backup memcached server ip and port -l ip, local bind ip address, default is 0.0.0.0 -n number, set max connections, default is 4096 -D don't go to background -k use ketama key ...

    自动备份sqlserver JOB 用脚本

    - 执行备份命令,例如`sqlcmd -S &lt;server_name&gt; -U &lt;username&gt; -P &lt;password&gt; -Q "BACKUP DATABASE &lt;database_name&gt; TO DISK = '&lt;backup_path&gt;\&lt;database_name&gt;_bak.bak'"`。 - 或者,它可能调用PowerShell脚本`...

    Office SharePoint Server 2007 Administrator's Companion

    SharePoint Server 2007管理员手册(全书)英文版 Get your mission-critical collaboration and information-management systems up and running with this ... Apply best practices for backup and recovery

    sqlserver数据库自动备份

    - 在“添加参数”中,输入SQL脚本的路径以及执行备份的命令,如:`-S .\YourInstanceName -U YourUsername -P YourPassword -Q "YOUR_BACKUP_SCRIPT"`。 3. **考虑备份策略** - 定期性:根据业务需求设定备份频率...

    dotfiles:我的个人配置文件

    我的个人配置文件。 Mac/Linux ...$ ln -s $PWD /.zshrc ~ /.zshrc $ chsh -s $( which zsh ) $ ln -s $PWD /.tmux.conf ~ /.tmux.conf ...$ ln -s minecraft-server.sh ~ /minecraft-server.sh $ ln -s .jshint.json

Global site tag (gtag.js) - Google Analytics