private boolean createDefinedIndexesForReplicatedRegion( HashSet<Index> indexes, Region region, Set<IndexCreationData> icds, HashMap<String, Exception> exceptionsMap) { boolean throwException = false; for (IndexCreationData icd : icds) { try { // First step is creating all the defined indexes. Do this only if // the region is not PR. For PR creation and population is done in // the PartitionedRegion#createDefinedIndexes indexes.add( createIndex( icd.getIndexName(), icd.getIndexType(), icd.getIndexExpression(), icd.getIndexFromClause(), icd.getIndexImportString(), false, region)); } catch (Exception ex) { // If an index creation fails, add the exception to the map and // continue creating rest of the indexes.The failed indexes will // be removed from the IndexManager#indexes map by the createIndex // method so that those indexes will not be populated in the next // step. if (logger.isDebugEnabled()) { logger.debug("Index creation failed, {}, {}", icd.getIndexName(), ex.getMessage(), ex); } exceptionsMap.put(icd.getIndexName(), ex); throwException = true; } } if (IndexManager.testHook != null) { IndexManager.testHook.hook(13); } // Second step is iterating over REs and populating all the created // indexes IndexManager indexManager = IndexUtils.getIndexManager(region, false); if (indexManager == null) { for (IndexCreationData icd : icds) { exceptionsMap.put( icd.getIndexName(), new IndexCreationException("Index Creation Failed due to region destroy")); } return true; } if (indexes.size() > 0) { try { indexManager.populateIndexes(indexes); } catch (MultiIndexCreationException ex) { exceptionsMap.putAll(ex.getExceptionsMap()); throwException = true; } } return throwException; }