BlurLockFactory lockFactory = new BlurLockFactory(_configuration, hdfsDirPath, _nodeName, BlurUtil.getPid());
Directory directory = new HdfsDirectory(_configuration, hdfsDirPath);
directory.setLockFactory(lockFactory);
TableDescriptor descriptor = _clusterStatus.getTableDescriptor(true, _cluster, table);
TableContext tableContext = TableContext.create(descriptor);
ShardContext shardContext = ShardContext.create(tableContext, shard);
Directory dir;
boolean blockCacheEnabled = _clusterStatus.isBlockCacheEnabled(_cluster, table);
if (blockCacheEnabled) {
Set<String> blockCacheFileTypes = _clusterStatus.getBlockCacheFileTypes(_cluster, table);
dir = _blockCacheDirectoryFactory.newDirectory(table + "_" + shard, directory, blockCacheFileTypes);
} else {
dir = directory;
}
BlurIndex index;
if (_clusterStatus.isReadOnly(true, _cluster, table)) {
BlurIndexReader reader = new BlurIndexReader(shardContext, dir, _refresher, _indexCloser);
index = reader;
} else {
BlurNRTIndex writer = new BlurNRTIndex(shardContext, _mergeScheduler, _closer, dir, _gc, _searchExecutor);
index = writer;
}
_filterCache.opening(table, shard, index);
TableDescriptor tableDescriptor = _clusterStatus.getTableDescriptor(true, _cluster, table);
warmUp(index, tableDescriptor, shard);
return index;
}