001package org.kuali.ole.docstore.discovery.service;
002
003import org.apache.solr.client.solrj.SolrServer;
004
005/**
006 * User: tirumalesh.b
007 * Date: 23/12/11 Time: 12:09 PM
008 */
009public class AdminServiceImpl implements AdminService {
010    private static AdminServiceImpl adminService = null;
011
012    private AdminServiceImpl() {
013    }
014
015    public static AdminService getInstance() {
016        if (null == adminService) {
017            adminService = new AdminServiceImpl();
018        }
019        return adminService;
020    }
021
022    @Override
023    public void optimize(String indexName) throws Exception {
024        SolrServer solr = SolrServerManager.getInstance().getSolrServer(indexName, false, false);
025        solr.optimize();
026    }
027
028    @Override
029    public void optimize() throws Exception {
030        SolrServer solr = SolrServerManager.getInstance().getSolrServer();
031        solr.optimize();
032        // TODO: Handle other cores also, if any.
033    }
034
035    @Override
036    public void optimize(Boolean waitFlush, Boolean waitSearcher) throws Exception {
037        SolrServer solr = SolrServerManager.getInstance().getSolrServer();
038        solr.optimize(false, false);
039    }
040}