This repository has been archived by the owner on Oct 30, 2020. It is now read-only.
/
SenseiServerBuilder.java
549 lines (450 loc) · 22.3 KB
/
SenseiServerBuilder.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
package com.sensei.conf;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.io.File;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.configuration.MapConfiguration;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.util.Version;
import org.jolokia.http.AgentServlet;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.thread.QueuedThreadPool;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.core.io.Resource;
import org.w3c.dom.Document;
import org.mortbay.servlet.GzipFilter;
import proj.zoie.api.indexing.ZoieIndexableInterpreter;
import proj.zoie.hourglass.impl.HourGlassScheduler.FREQUENCY;
import proj.zoie.impl.indexing.ZoieConfig;
import scala.actors.threadpool.Arrays;
import com.browseengine.bobo.facets.FacetHandler;
import com.browseengine.bobo.facets.RuntimeFacetHandlerFactory;
import com.linkedin.norbert.javacompat.cluster.ClusterClient;
import com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient;
import com.linkedin.norbert.javacompat.network.NettyNetworkServer;
import com.linkedin.norbert.javacompat.network.NetworkServer;
import com.linkedin.norbert.javacompat.network.NetworkServerConfig;
import com.sensei.indexing.api.DefaultJsonSchemaInterpreter;
import com.sensei.indexing.api.DefaultStreamingIndexingManager;
import com.sensei.indexing.api.DataSourceFilter;
import com.sensei.indexing.api.SenseiIndexPruner;
import com.sensei.search.client.servlet.DefaultSenseiJSONServlet;
import com.sensei.search.client.servlet.SenseiConfigServletContextListener;
import com.sensei.search.client.servlet.SenseiHttpInvokerServiceServlet;
import com.sensei.search.cluster.routing.UniformPartitionedRoutingFactory;
import com.sensei.search.cluster.routing.SenseiLoadBalancerFactory;
import com.sensei.search.nodes.SenseiCore;
import com.sensei.search.nodes.SenseiHourglassFactory;
import com.sensei.search.nodes.SenseiIndexReaderDecorator;
import com.sensei.search.nodes.SenseiIndexingManager;
import com.sensei.search.nodes.SenseiQueryBuilderFactory;
import com.sensei.search.nodes.SenseiServer;
import com.sensei.search.nodes.SenseiZoieFactory;
import com.sensei.search.nodes.SenseiZoieSystemFactory;
import com.sensei.search.nodes.impl.DefaultJsonQueryBuilderFactory;
import com.sensei.search.nodes.impl.SenseiTimeFilter;
import com.sensei.search.req.AbstractSenseiRequest;
import com.sensei.search.req.AbstractSenseiResult;
import com.sensei.search.req.SenseiSystemInfo;
import com.sensei.search.svc.impl.AbstractSenseiCoreService;
public class SenseiServerBuilder implements SenseiConfParams{
private static Logger logger = Logger.getLogger(SenseiServerBuilder.class);
public static final String SENSEI_PROPERTIES = "sensei.properties";
public static final String CUSTOM_FACETS = "custom-facets.xml";
public static final String SCHEMA_FILE = "schema.xml";
public static final String PLUGINS = "plugins.xml";
private final File _senseiConfFile;
private final Configuration _senseiConf;
private final ApplicationContext _pluginContext;
private final ApplicationContext _customFacetContext;
private final Document _schemaDoc;
private final SenseiSchema _senseiSchema;
private final Server _jettyServer;
private final Comparator<String> _versionComparator;
public static final Map<String,TimeUnit> TimeUnitStringMap = new HashMap<String,TimeUnit>();
static{
TimeUnitStringMap.put("days",TimeUnit.DAYS);
TimeUnitStringMap.put("seconds",TimeUnit.SECONDS);
TimeUnitStringMap.put("milliseconds",TimeUnit.MILLISECONDS);
}
private static ApplicationContext loadSpringContext(File confFile){
ApplicationContext springCtx = null;
if (confFile.exists()){
springCtx = new FileSystemXmlApplicationContext("file:"+confFile.getAbsolutePath());
}
return springCtx;
}
public ClusterClient buildClusterClient()
{
String clusterName = _senseiConf.getString(SENSEI_CLUSTER_NAME);
String zkUrl = _senseiConf.getString(SENSEI_CLUSTER_URL);
int zkTimeout = _senseiConf.getInt(SENSEI_CLUSTER_TIMEOUT, 300000);
ClusterClient clusterClient = new ZooKeeperClusterClient(clusterName, zkUrl,zkTimeout);
logger.info("Connecting to cluster: "+clusterName+" ...");
clusterClient.awaitConnectionUninterruptibly();
logger.info("Cluster: "+clusterName+" successfully connected ");
return clusterClient;
}
private static NetworkServer buildNetworkServer(Configuration conf,ClusterClient clusterClient){
NetworkServerConfig networkConfig = new NetworkServerConfig();
networkConfig.setClusterClient(clusterClient);
networkConfig.setRequestThreadCorePoolSize(conf.getInt(SERVER_REQ_THREAD_POOL_SIZE, 20));
networkConfig.setRequestThreadMaxPoolSize(conf.getInt(SERVER_REQ_THREAD_POOL_MAXSIZE,70));
networkConfig.setRequestThreadKeepAliveTimeSecs(conf.getInt(SERVER_REQ_THREAD_POOL_KEEPALIVE,300));
return new NettyNetworkServer(networkConfig);
}
static{
try{
org.mortbay.log.Log.setLog(new org.mortbay.log.Slf4jLog());
}
catch(Throwable t){
logger.error(t.getMessage(),t);
}
}
public Server buildHttpRestServer() throws Exception{
int port = _senseiConf.getInt(SERVER_BROKER_PORT);
String webappPath = _senseiConf.getString(SERVER_BROKER_WEBAPP_PATH);
Server server = new Server();
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("Sensei Broker(jetty) threads");
threadPool.setMinThreads(_senseiConf.getInt(SERVER_BROKER_MINTHREAD,20));
threadPool.setMaxThreads(_senseiConf.getInt(SERVER_BROKER_MAXTHREAD,50));
threadPool.setMaxIdleTimeMs(_senseiConf.getInt(SERVER_BROKER_MAXWAIT,2000));
//threadPool.start();
server.setThreadPool(threadPool);
logger.info("request threadpool started.");
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
server.addConnector(connector);
DefaultSenseiJSONServlet senseiServlet = new DefaultSenseiJSONServlet();
ServletHolder senseiServletHolder = new ServletHolder(senseiServlet);
SenseiHttpInvokerServiceServlet springServlet = new SenseiHttpInvokerServiceServlet();
ServletHolder springServletHolder = new ServletHolder(springServlet);
AgentServlet jmxServlet = new AgentServlet();
ServletHolder jmxServletHolder = new ServletHolder(jmxServlet);
WebAppContext senseiApp = new WebAppContext();
senseiApp.addFilter(GzipFilter.class,"/sensei/*",1);
//HashMap<String, String> initParam = new HashMap<String, String>();
//if (_senseiConfFile != null) {
//logger.info("Broker Configuration file: "+_senseiConfFile.getAbsolutePath());
//initParam.put("config.file", _senseiConfFile.getAbsolutePath());
//}
//senseiApp.setInitParams(initParam);
senseiApp.setAttribute("sensei.search.configuration", _senseiConf);
senseiApp.setAttribute("sensei.search.version.comparator", _versionComparator);
SenseiLoadBalancerFactory routerFactory = null;
String routerFactoryName = _senseiConf.getString(SERVER_SEARCH_ROUTER_FACTORY, "");
if (routerFactoryName == null || routerFactoryName.equals(""))
routerFactory = new UniformPartitionedRoutingFactory();
else
routerFactory = (SenseiLoadBalancerFactory) _pluginContext.getBean(routerFactoryName);
senseiApp.setAttribute("sensei.search.router.factory", routerFactory);
senseiApp.addEventListener(new SenseiConfigServletContextListener());
senseiApp.addServlet(senseiServletHolder,"/sensei/*");
//senseiApp.addFilter(new FilterHolder(new GzipFilter()), "/sensei/*", 1);
senseiApp.setResourceBase(webappPath);
senseiApp.addServlet(springServletHolder,"/sensei-rpc/SenseiSpringRPCService");
senseiApp.addServlet(jmxServletHolder,"/admin/jmx/*");
server.setHandler(senseiApp);
server.setStopAtShutdown(true);
return server;
}
public SenseiServerBuilder(File confDir, Map<String, Object> properties, ApplicationContext customFacetContext,
ApplicationContext pluginContext) throws Exception {
if (properties != null) {
_senseiConfFile = null;
_senseiConf = new MapConfiguration(properties);
}
else {
_senseiConfFile = new File(confDir,SENSEI_PROPERTIES);
if (!_senseiConfFile.exists()){
throw new ConfigurationException("configuration file: "+_senseiConfFile.getAbsolutePath()+" does not exist.");
}
_senseiConf = new PropertiesConfiguration(_senseiConfFile);
}
if (pluginContext != null)
_pluginContext = pluginContext;
else
_pluginContext = loadSpringContext(new File(confDir,PLUGINS));
String versionComparatorName = _senseiConf.getString(SENSEI_VERSION_COMPARATOR, "");
if (versionComparatorName == null || versionComparatorName.equals(""))
_versionComparator = ZoieConfig.DEFAULT_VERSION_COMPARATOR;
else
_versionComparator = (Comparator<String>) _pluginContext.getBean(versionComparatorName);
if (customFacetContext != null)
_customFacetContext = customFacetContext;
else
_customFacetContext = loadSpringContext(new File(confDir,CUSTOM_FACETS));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setIgnoringComments(true);
DocumentBuilder db = dbf.newDocumentBuilder();
_schemaDoc = db.parse(new File(confDir,SCHEMA_FILE));
_schemaDoc.getDocumentElement().normalize();
_senseiSchema = SenseiSchema.build(_schemaDoc);
_jettyServer = buildHttpRestServer();
}
public SenseiServerBuilder(File confDir, Map<String, Object> properties, ApplicationContext customFacetContext) throws Exception {
this(confDir, properties, customFacetContext, null);
}
public SenseiServerBuilder(File confDir, Map<String, Object> properties) throws Exception {
this(confDir, properties, null, null);
}
public SenseiServerBuilder(File confDir) throws Exception {
this(confDir, null, null, null);
}
public SenseiServerBuilder(Resource confDir, Map<String, Object> properties, ApplicationContext customFacetContext,
ApplicationContext pluginContext) throws Exception {
_senseiConfFile = null;
_senseiConf = new MapConfiguration(properties);
//TODO: conditionally load other contexts.
_pluginContext = pluginContext;
String versionComparatorName = _senseiConf.getString(SENSEI_VERSION_COMPARATOR, "");
if (versionComparatorName == null || versionComparatorName.equals(""))
_versionComparator = ZoieConfig.DEFAULT_VERSION_COMPARATOR;
else
_versionComparator = (Comparator<String>) _pluginContext.getBean(versionComparatorName);
_customFacetContext = customFacetContext;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setIgnoringComments(true);
DocumentBuilder db = dbf.newDocumentBuilder();
_schemaDoc = db.parse(confDir.createRelative(SCHEMA_FILE).getInputStream());
_schemaDoc.getDocumentElement().normalize();
_senseiSchema = SenseiSchema.build(_schemaDoc);
_jettyServer = buildHttpRestServer();
}
//public SenseiServerBuilder(Resource confDir, Map<String, Object> properties, ApplicationContext customFacetContext) throws Exception {
//this(confDir, properties, customFacetContext, null);
//}
//public SenseiServerBuilder(Resource confDir, Map<String, Object> properties) throws Exception {
//this(confDir, properties, null, null);
//}
//public SenseiServerBuilder(Resource confDir) throws Exception {
//this(confDir, null, null, null);
//}
static final Pattern PARTITION_PATTERN = Pattern.compile("[\\d]+||[\\d]+-[\\d]+");
public static int[] buildPartitions(String[] partitionArray) throws ConfigurationException{
IntSet partitions = new IntOpenHashSet();
try {
for (int i=0; i<partitionArray.length; ++i) {
Matcher matcher = PARTITION_PATTERN.matcher(partitionArray[i]);
if (!matcher.matches()){
throw new ConfigurationException("Invalid partition: "+partitionArray[i]);
}
String[] partitionRange = partitionArray[i].split("-");
int start = Integer.parseInt(partitionRange[0]);
int end;
if (partitionRange.length>1){
end = Integer.parseInt(partitionRange[1]);
if (end<start){
throw new ConfigurationException("invalid partition range: "+partitionArray[i]);
}
}
else{
end = start;
}
for (int k=start;k<=end;++k){
partitions.add(k);
}
}
}
catch (Exception e) {
throw new ConfigurationException(
"Error parsing '" + SENSEI_PROPERTIES + "': " + PARTITIONS + "=" + Arrays.toString(partitionArray), e);
}
return partitions.toIntArray();
}
public SenseiCore buildCore() throws ConfigurationException{
int nodeid = _senseiConf.getInt(NODE_ID);
String[] partitionArray = _senseiConf.getStringArray(PARTITIONS);
int[] partitions = buildPartitions(partitionArray);
logger.info("partitions to serve: "+Arrays.toString(partitions));
// Analyzer from configuration:
Analyzer analyzer = null;
String analyzerName = _senseiConf.getString(SENSEI_INDEX_ANALYZER, "");
if (analyzerName == null || analyzerName.equals("")) {
analyzer = new StandardAnalyzer(Version.LUCENE_30);
}
else {
analyzer = (Analyzer)_pluginContext.getBean(analyzerName);
}
// Similarity from configuration:
Similarity similarity = null;
String similarityName = _senseiConf.getString(SENSEI_INDEX_SIMILARITY, "");
if (similarityName == null || similarityName.equals("")) {
similarity = new DefaultSimilarity();
}
else {
similarity = (Similarity)_pluginContext.getBean(similarityName);
}
ZoieConfig zoieConfig = new ZoieConfig(_versionComparator);
zoieConfig.setAnalyzer(analyzer);
zoieConfig.setSimilarity(similarity);
zoieConfig.setBatchSize(_senseiConf.getInt(SENSEI_INDEX_BATCH_SIZE,ZoieConfig.DEFAULT_SETTING_BATCHSIZE));
zoieConfig.setBatchDelay(_senseiConf.getLong(SENSEI_INDEX_BATCH_DELAY, ZoieConfig.DEFAULT_SETTING_BATCHDELAY));
zoieConfig.setMaxBatchSize(_senseiConf.getInt(SENSEI_INDEX_BATCH_MAXSIZE, ZoieConfig.DEFAULT_MAX_BATCH_SIZE));
zoieConfig.setRtIndexing(_senseiConf.getBoolean(SENSEI_INDEX_REALTIME, ZoieConfig.DEFAULT_SETTING_REALTIME));
zoieConfig.setFreshness(_senseiConf.getLong(SENSEI_INDEX_FRESHNESS, 500));
List<FacetHandler<?>> facetHandlers = new LinkedList<FacetHandler<?>>();
List<RuntimeFacetHandlerFactory<?,?>> runtimeFacetHandlerFactories = new LinkedList<RuntimeFacetHandlerFactory<?,?>>();
SenseiSystemInfo sysInfo = SenseiFacetHandlerBuilder.buildFacets(_schemaDoc,
_customFacetContext, facetHandlers, runtimeFacetHandlerFactories);
if (sysInfo != null)
{
try
{
List<SenseiSystemInfo.SenseiNodeInfo> clusterInfo = new ArrayList(1);
clusterInfo.add(new SenseiSystemInfo.SenseiNodeInfo(nodeid, partitions,
(new InetSocketAddress(InetAddress.getLocalHost().getHostAddress(),
_senseiConf.getInt(SERVER_PORT))).toString().replaceAll("/", ""),
"http://"+(new InetSocketAddress(InetAddress.getLocalHost().getHostAddress(),
_senseiConf.getInt(SERVER_BROKER_PORT))).toString().replaceAll("/", "")));
sysInfo.setClusterInfo(clusterInfo);
}
catch(Exception e)
{
throw new ConfigurationException(e.getMessage(), e);
}
}
String indexerType = _senseiConf.getString(SENSEI_INDEXER_TYPE);
String interpreterType = _senseiConf.getString(SENSEI_INDEX_INTERPRETER,"");
ZoieIndexableInterpreter interpreter;
if (interpreterType.length()==0){
interpreter = new DefaultJsonSchemaInterpreter(_senseiSchema);
}
else{
interpreter = (ZoieIndexableInterpreter)_pluginContext.getBean(interpreterType);
}
SenseiIndexReaderDecorator decorator = new SenseiIndexReaderDecorator(facetHandlers,runtimeFacetHandlerFactories);
File idxDir = new File(_senseiConf.getString(SENSEI_INDEX_DIR));
SenseiZoieFactory<?> zoieSystemFactory = null;
if (SENSEI_INDEXER_TYPE_ZOIE.equals(indexerType)){
SenseiZoieSystemFactory zoieFactory = new SenseiZoieSystemFactory(idxDir,interpreter,decorator,
zoieConfig);
zoieSystemFactory = zoieFactory;
int retentionDays = _senseiConf.getInt(SENSEI_ZOIE_RETENTION_DAYS,-1);
if (retentionDays>0){
String retentionField=_senseiConf.getString(SENSEI_ZOIE_RETENTION_FIELD);
String retentionTimeUnit=_senseiConf.getString(SENSEI_ZOIE_RETENTION_TIMEUNIT).toLowerCase();
TimeUnit timeUnit = TimeUnitStringMap.get(retentionTimeUnit);
if (timeUnit==null){
throw new ConfigurationException("invalid timeunit: "+timeUnit+", only days/seconds/milliseconds supported");
}
SenseiTimeFilter purgeFilter = new SenseiTimeFilter(retentionField, timeUnit, retentionDays);
zoieFactory.setPurgeFilter(purgeFilter);
}
}
else if (SENSEI_INDEXER_TYPE_HOURGLASS.equals(indexerType)){
String schedule = _senseiConf.getString(SENSEI_HOURGLASS_SCHEDULE,"");
int trimThreshold = _senseiConf.getInt(SENSEI_HOURGLASS_TRIMTHRESHOLD,14);
String frequencyString = _senseiConf.getString(SENSEI_HOURGLASS_FREQUENCY,"day");
FREQUENCY frequency;
if (SENSEI_HOURGLASS_FREQUENCY_MIN.equals(frequencyString)){
frequency = FREQUENCY.MINUTELY;
}
else if (SENSEI_HOURGLASS_FREQUENCY_HOUR.equals(frequencyString)){
frequency = FREQUENCY.HOURLY;
}
else if (SENSEI_HOURGLASS_FREQUENCY_DAY.equals(frequencyString)){
frequency = FREQUENCY.DAILY;
}
else{
throw new ConfigurationException("unsupported frequency setting: "+frequencyString);
}
zoieSystemFactory = new SenseiHourglassFactory(idxDir,interpreter,decorator,
zoieConfig,schedule,trimThreshold,frequency);
}
else{
ZoieFactoryFactory zoieFactoryFactory= (ZoieFactoryFactory)_pluginContext.getBean(indexerType);
if (zoieFactoryFactory==null){
throw new ConfigurationException(indexerType+" not defined");
}
zoieSystemFactory = zoieFactoryFactory.getZoieFactory(idxDir, interpreter, decorator, zoieConfig);
}
String idxMgrType = _senseiConf.getString(SENSEI_INDEX_MANAGER,"");
SenseiIndexingManager<?> indexingManager;
if (idxMgrType.length()==0){
String uidField = _senseiSchema.getUidField();
indexingManager = new DefaultStreamingIndexingManager(_senseiSchema,_senseiConf, _pluginContext, _versionComparator);
}
else{
indexingManager = (SenseiIndexingManager)_pluginContext.getBean(idxMgrType);
}
SenseiQueryBuilderFactory queryBuilderFactory = null;
String qbuilderFactory = _senseiConf.getString(SENSEI_QUERY_BUILDER_FACTORY,"");
if (qbuilderFactory.length()==0){
QueryParser queryParser = new QueryParser(Version.LUCENE_30,"contents", analyzer);
queryBuilderFactory = new DefaultJsonQueryBuilderFactory(queryParser);
}
else{
queryBuilderFactory = (SenseiQueryBuilderFactory)_pluginContext.getBean(qbuilderFactory);
}
SenseiCore senseiCore = new SenseiCore(nodeid,partitions,zoieSystemFactory,indexingManager,queryBuilderFactory);
senseiCore.setSystemInfo(sysInfo);
String senseiPrunerClass = _senseiConf.getString(SENSEI_INDEX_PRUNER,"");
if (senseiPrunerClass.length()>0){
SenseiIndexPruner pruner = (SenseiIndexPruner)_pluginContext.getBean(senseiPrunerClass);
senseiCore.setIndexPruner(pruner);
}
return senseiCore;
}
public Server getJettyServer(){
return _jettyServer;
}
public Comparator<String> getVersionComparator() {
return _versionComparator;
}
public SenseiServer buildServer() throws ConfigurationException {
int port = _senseiConf.getInt(SERVER_PORT);
ClusterClient clusterClient = buildClusterClient();
NetworkServer networkServer = buildNetworkServer(_senseiConf,clusterClient);
SenseiCore core = buildCore();
String[] externalServicList = _senseiConf.getStringArray(SENSEI_PLUGIN_SVCS);
List<AbstractSenseiCoreService<AbstractSenseiRequest, AbstractSenseiResult>> svcList = new LinkedList<AbstractSenseiCoreService<AbstractSenseiRequest, AbstractSenseiResult>>();
if (externalServicList!=null){
for (String svcName : externalServicList){
if (svcName!=null && svcName.trim().length()>0){
try{
AbstractSenseiCoreService<AbstractSenseiRequest, AbstractSenseiResult> svc = (AbstractSenseiCoreService<AbstractSenseiRequest, AbstractSenseiResult>)_pluginContext.getBean(svcName);
svcList.add(svc);
}
catch(Exception e){
throw new ConfigurationException(e.getMessage(),e);
}
}
}
}
return new SenseiServer(port,networkServer,clusterClient,core,svcList);
}
/*
public HttpAdaptor buildJMXAdaptor(){
int jmxport = _senseiConf.getInt(SENSEI_MX4J_PORT,15555);
HttpAdaptor httpAdaptor = new HttpAdaptor(jmxport);
httpAdaptor.setHost("0.0.0.0");
return httpAdaptor;
}
*/
}