extensibleIndexes = new ExtensibleMatchingRuleIndex();
}
IndexConfig config = new JEIndexConfig(cfg.getSubstringLength());
for(String ruleName:extensibleRules)
{
ExtensibleMatchingRule rule =
DirectoryServer.getExtensibleMatchingRule(
toLowerCase(ruleName));
if(rule == null)
{
Message message =
ERR_CONFIG_INDEX_TYPE_NEEDS_VALID_MATCHING_RULE.get(
String.valueOf(attrType),ruleName);
logError(message);
continue;
}
validRules.add(rule);
Map<String,Index> indexMap = new HashMap<String,Index>();
for(ExtensibleIndexer indexer: rule.getIndexers(config))
{
String indexerId = indexer.getExtensibleIndexID();
String indexID =
attrType.getNameOrOID() + "."
+ indexer.getPreferredIndexName()
+ "." + indexerId;
if(!extensibleIndexes.isIndexPresent(indexID))
{
Indexer extensibleIndexer =
new JEExtensibleIndexer(attrType,
rule,
indexer);
String indexName = entryContainer.getDatabasePrefix() + "_"
+ indexID;
Index extensibleIndex = new Index(indexName,
extensibleIndexer,
state,
indexEntryLimit,
cursorEntryLimit,
false,
env,
entryContainer);
extensibleIndexes.addIndex(extensibleIndex,indexID);
extensibleIndex.open();
if(!extensibleIndex.isTrusted())
{
adminActionRequired = true;
messages.add(NOTE_JEB_INDEX_ADD_REQUIRES_REBUILD.get(
extensibleIndex.getName()));
}
}
else
{
Index extensibleIndex = extensibleIndexes.getIndex(indexID);
if(extensibleIndex.setIndexEntryLimit(indexEntryLimit))
{
adminActionRequired = true;
Message message =
NOTE_JEB_CONFIG_INDEX_ENTRY_LIMIT_REQUIRES_REBUILD.get(
extensibleIndex.getName());
messages.add(message);
}
if(indexConfig.getSubstringLength() !=
cfg.getSubstringLength())
{
Indexer extensibleIndexer =
new JEExtensibleIndexer(attrType,
rule,
indexer);
extensibleIndex.setIndexer(extensibleIndexer);
}
}
extensibleIndexes.addRule(indexID, rule);
indexMap.put(indexerId,extensibleIndexes.getIndex(indexID));
}
IndexQueryFactory<IndexQuery> factory =
new IndexQueryFactoryImpl(indexMap);
extensibleIndexes.addQueryFactory(rule, factory);
}
//Some rules might have been removed from the configuration.
Set<ExtensibleMatchingRule> deletedRules =
new HashSet<ExtensibleMatchingRule>();
for(ExtensibleMatchingRule r:extensibleIndexes.getRules())
{
if(!validRules.contains(r))
{
deletedRules.add(r);
}
}
if(deletedRules.size() > 0)
{
entryContainer.exclusiveLock.lock();
try
{
for(ExtensibleMatchingRule rule:deletedRules)
{
Set<ExtensibleMatchingRule> rules =
new HashSet<ExtensibleMatchingRule>();
List<String> ids = new ArrayList<String>();
for(ExtensibleIndexer indexer: rule.getIndexers(config))
{
String id = attrType.getNameOrOID() + "."
+ indexer.getPreferredIndexName()
+ "." + indexer.getExtensibleIndexID();
rules.addAll(extensibleIndexes.getRules(id));