indexerProcessId = indexerProcessRegistry.registerIndexerProcess(indexerDef.getName(), hostName);
indexerProcessIds.put(indexerDef.getName(), indexerProcessId);
// Create and register the indexer
IndexerComponentFactory factory = IndexerComponentFactoryUtil.getComponentFactory(indexerDef.getIndexerComponentFactory(), new ByteArrayInputStream(indexerDef.getConfiguration()), indexerDef.getConnectionParams());
IndexerConf indexerConf = factory.createIndexerConf();
ResultToSolrMapper mapper = factory.createMapper(indexerDef.getName());
Sharder sharder = null;
SolrInputDocumentWriter solrWriter;
PoolingClientConnectionManager connectionManager = null;
if (indexerDef.getConnectionType() == null || indexerDef.getConnectionType().equals("solr")) {
Map<String, String> connectionParams = indexerDef.getConnectionParams();
String solrMode = SolrConnectionParamUtil.getSolrMode(connectionParams);
if (solrMode.equals("cloud")) {
solrWriter = new DirectSolrInputDocumentWriter(indexerDef.getName(), createCloudSolrServer(connectionParams));
} else if (solrMode.equals("classic")) {
connectionManager = new PoolingClientConnectionManager();
connectionManager.setDefaultMaxPerRoute(getSolrMaxConnectionsPerRoute(connectionParams));
connectionManager.setMaxTotal(getSolrMaxConnectionsTotal(connectionParams));
httpClient = new DefaultHttpClient(connectionManager);
List<SolrServer> solrServers = createHttpSolrServers(connectionParams, httpClient);
solrWriter = new DirectSolrClassicInputDocumentWriter(indexerDef.getName(), solrServers);
sharder = createSharder(connectionParams, solrServers.size());
} else {
throw new RuntimeException("Only 'cloud' and 'classic' are valid values for solr.mode, but got " + solrMode);
}
} else {
throw new RuntimeException(
"Invalid connection type: " + indexerDef.getConnectionType() + ". Only 'solr' is supported");
}
Indexer indexer = Indexer.createIndexer(indexerDef.getName(), indexerConf, indexerConf.getTable(),
mapper, htablePool, sharder, solrWriter);
IndexingEventListener eventListener = new IndexingEventListener(
indexer, indexerConf.getTable(), indexerConf.tableNameIsRegex());
int threads = hbaseConf.getInt("hbaseindexer.indexer.threads", 10);
SepConsumer sepConsumer = new SepConsumer(indexerDef.getSubscriptionId(),
indexerDef.getSubscriptionTimestamp(), eventListener, threads, hostName,
zk, hbaseConf, null);