CacheSerializableRunnable getCacheSerializableRunnableForRemoveIndex(final String name,
      final boolean random) {
    return new CacheSerializableRunnable("PrRemoveIndex") {
      @Override
      public void run2() {

        Cache cache1 = getCache();
        LogWriter logger = cache1.getLogger();
        logger.info("Got the following cache : " + cache1);
        Region parRegion = cache1.getRegion(name);
        QueryService qs = cache1.getQueryService();
        if (!random) {
          Collection indexes = qs.getIndexes();
          assertEquals(3, indexes.size());
          for (final Object index : indexes) {
            logger.info("Following indexes found : " + index);
          }
          qs.removeIndexes(parRegion);
          logger.info("Removed all the index on this paritioned regions : " + parRegion);
          indexes = qs.getIndexes();
          assertEquals(0, ((LocalRegion) parRegion).getIndexManager().getIndexes().size());
          assertEquals(0, indexes.size());

          // should not cause any kind of exception just a check.
          qs.removeIndexes(parRegion);
        } else {
          // pick a random index and remvoe it
          Collection indexes = qs.getIndexes(parRegion);
          assertEquals(3, indexes.size());
          assertEquals(3, ((LocalRegion) parRegion).getIndexManager().getIndexes().size());
          synchronized (indexes) {
            for (final Object index : indexes) {
              Index in = (Index) index;
              qs.removeIndex(in);
            }
          }
          indexes = qs.getIndexes(parRegion);
          assertEquals(0, indexes.size());
          assertEquals(0, ((LocalRegion) parRegion).getIndexManager().getIndexes().size());
        }

      } // ends run
    };
  }
Cacheserializable runnable which removes all the index on a partitioned region

@param name name of the partitioned regions
geode-core/src/distributedTest/java/org/apache/geode/cache/query/partitioned/PRQueryDUnitHelper.java