private boolean createDefinedIndexesForPR(
     HashSet<Index> indexes,
     PartitionedRegion region,
     HashSet<IndexCreationData> icds,
     HashMap<String, Exception> exceptionsMap) {
   try {
     indexes.addAll(((PartitionedRegion) region).createIndexes(false, icds));
   } catch (IndexCreationException e1) {
     logger.info(
         LocalizedMessage.create(
             LocalizedStrings
                 .DefaultQueryService_EXCEPTION_WHILE_CREATING_INDEX_ON_PR_DEFAULT_QUERY_PROCESSOR),
         e1);
   } catch (CacheException e1) {
     logger.info(
         LocalizedMessage.create(
             LocalizedStrings
                 .DefaultQueryService_EXCEPTION_WHILE_CREATING_INDEX_ON_PR_DEFAULT_QUERY_PROCESSOR),
         e1);
     return true;
   } catch (ForceReattemptException e1) {
     logger.info(
         LocalizedMessage.create(
             LocalizedStrings
                 .DefaultQueryService_EXCEPTION_WHILE_CREATING_INDEX_ON_PR_DEFAULT_QUERY_PROCESSOR),
         e1);
     return true;
   } catch (MultiIndexCreationException e) {
     exceptionsMap.putAll(e.getExceptionsMap());
     return true;
   }
   return false;
 }
  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;
  }