protected ViewDataMigrator getViewDataMigrator(ViewInstanceEntity currentInstanceDefinition,
                                                        ViewDataMigrationContextImpl migrationContext)
      throws ViewDataMigrationException {
    ViewDataMigrator dataMigrator;

    LOG.info("Migrating " + currentInstanceDefinition.getInstanceName() +
        " data from " + migrationContext.getOriginDataVersion() + " to " +
        migrationContext.getCurrentDataVersion() + " data version");

    if (migrationContext.getOriginDataVersion() == migrationContext.getCurrentDataVersion()) {

      LOG.info("Instances of same version, copying all data.");
      dataMigrator = new CopyAllDataMigrator(migrationContext);
    } else {
      try {
        dataMigrator = currentInstanceDefinition.getDataMigrator(migrationContext);
        if (dataMigrator == null) {
          throw new ViewDataMigrationException("A view instance " +
              currentInstanceDefinition.getInstanceName() + " does not support migration.");
        }
        LOG.debug("Data migrator loaded");
      } catch (ClassNotFoundException e) {
        String msg = "Caught exception loading data migrator of " + currentInstanceDefinition.getInstanceName();

        LOG.error(msg, e);
        throw new RuntimeException(msg);
      }
    }
    return dataMigrator;
  }
Get the migrator instance for view instance with injected migration context.
If versions of instances are same returns copy-all-data migrator.
If versions are different, loads the migrator from the current view (view should
contain ViewDataMigrator implementation, otherwise exception will be raised).

@param currentInstanceDefinition    the current view instance definition
@param migrationContext             the migration context to inject into migrator
@throws ViewDataMigrationException  if view does not support migration
@return  the data migration instance
ambari-server/src/main/java/org/apache/ambari/server/view/ViewDataMigrationUtility.java