1 /*
2 * This file is part of *** M y C o R e ***
3 * See http://www.mycore.de/ for details.
4 *
5 * MyCoRe is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * MyCoRe is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with MyCoRe. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 package org.mycore.solr.index;
20
21 import java.io.IOException;
22 import java.util.List;
23 import java.util.concurrent.Callable;
24
25 import org.apache.solr.client.solrj.SolrServerException;
26
27 /**
28 * Solr index task which handles <code>MCRSolrIndexHandler</code>'s.
29 *
30 * @author Matthias Eichner
31 */
32 public class MCRSolrIndexTask implements Callable<List<MCRSolrIndexHandler>> {
33
34 protected MCRSolrIndexHandler indexHandler;
35
36 /**
37 * Creates a new solr index task.
38 *
39 * @param indexHandler
40 * handles the index process
41 */
42 public MCRSolrIndexTask(MCRSolrIndexHandler indexHandler) {
43 this.indexHandler = indexHandler;
44 }
45
46 @Override
47 public List<MCRSolrIndexHandler> call() throws SolrServerException, IOException {
48 long start = System.currentTimeMillis();
49 this.indexHandler.index();
50 long end = System.currentTimeMillis();
51 indexHandler.getStatistic().addDocument(indexHandler.getDocuments());
52 indexHandler.getStatistic().addTime(end - start);
53 return this.indexHandler.getSubHandlers();
54 }
55
56 @Override
57 public String toString() {
58 return "Solr: " + this.indexHandler;
59 }
60
61 }