private void saveMigratorSequence(
     SessionImpl session, DependencySequence migratorDependencySequence)
     throws AccessDeniedException, StorageClientException {
   Content runMigrators = session.getContentManager().get(SYSTEM_MIGRATION_CONTENT_ITEM);
   String ts = String.valueOf(System.currentTimeMillis());
   int i = 0;
   if (runMigrators == null) {
     Builder<String, Object> b = ImmutableMap.builder();
     for (PropertyMigrator pm : migratorDependencySequence) {
       b.put(pm.getName(), ts + ";" + i);
     }
     runMigrators = new Content(SYSTEM_MIGRATION_CONTENT_ITEM, b.build());
   } else {
     for (PropertyMigrator pm : migratorDependencySequence) {
       runMigrators.setProperty(pm.getName(), ts + ";" + i);
     }
   }
   session.getContentManager().update(runMigrators);
 }
 private void reindex(
     boolean dryRun,
     JDBCStorageClient jdbcClient,
     CacheAwareMigrationManager migrationManager,
     String keySpace,
     String columnFamily,
     Indexer indexer,
     DependencySequence propertyMigrators,
     IdExtractor idExtractor,
     int limit,
     Feedback feedback,
     boolean reindexAll)
     throws StorageClientException {
   long objectCount = jdbcClient.allCount(keySpace, columnFamily);
   LOGGER.info(
       "DryRun:{} Migrating {} objects in {} ", new Object[] {dryRun, objectCount, columnFamily});
   feedback.log(
       "DryRun:{0} Migrating {1} objects in {2} ",
       new Object[] {dryRun, objectCount, columnFamily});
   if (objectCount > 0) {
     DisposableIterator<SparseRow> allObjects = jdbcClient.listAll(keySpace, columnFamily);
     try {
       long c = 0;
       while (allObjects.hasNext()) {
         Map<String, PreparedStatement> statementCache = Maps.newHashMap();
         SparseRow r = allObjects.next();
         c++;
         if (c % 1000 == 0) {
           LOGGER.info(
               "DryRun:{} {}% remaining {} ",
               new Object[] {dryRun, ((c * 100) / objectCount), objectCount - c});
           feedback.progress(dryRun, c, objectCount);
         }
         try {
           Map<String, Object> properties = r.getProperties();
           String rid = r.getRowId();
           boolean save = false;
           for (PropertyMigrator propertyMigrator : propertyMigrators) {
             save = propertyMigrator.migrate(rid, properties) || save;
           }
           String key = idExtractor.getKey(properties);
           if (key != null) {
             if (!dryRun) {
               if (save) {
                 migrationManager.insert(keySpace, columnFamily, key, properties, false);
               } else if (reindexAll) {
                 indexer.index(statementCache, keySpace, columnFamily, key, rid, properties);
               }
             } else {
               if (c > limit) {
                 LOGGER.info("Dry Run Migration Stoped at {} Objects ", limit);
                 feedback.log("Dry Run Migration Stoped at {0} Objects ", limit);
                 break;
               }
             }
           } else {
             LOGGER.info("DryRun:{} Skipped Reindexing, no key in  {}", dryRun, properties);
             feedback.log("DryRun:{0} Skipped Reindexing, no key in  {1}", dryRun, properties);
           }
         } catch (SQLException e) {
           LOGGER.warn(e.getMessage(), e);
           feedback.exception(e);
         } catch (StorageClientException e) {
           LOGGER.warn(e.getMessage(), e);
           feedback.exception(e);
         } finally {
           jdbcClient.closeStatementCache(statementCache);
         }
       }
     } finally {
       allObjects.close();
     }
   }
 }