Пример #1
0
 /**
  * This is the main driver for recursively copying directories across file systems. It takes at
  * least two cmdline parameters. A source URL and a destination URL. It then essentially does an
  * "ls -lR" on the source URL, and writes the output in a round-robin manner to all the map input
  * files. The mapper actually copies the files allotted to it. The reduce is empty.
  */
 public int run(String[] args) {
   try {
     copy(conf, Arguments.valueOf(args, conf));
     return 0;
   } catch (IllegalArgumentException e) {
     System.err.println(StringUtils.stringifyException(e) + "\n" + usage);
     ToolRunner.printGenericCommandUsage(System.err);
     return -1;
   } catch (DuplicationException e) {
     System.err.println(StringUtils.stringifyException(e));
     return DuplicationException.ERROR_CODE;
   } catch (RemoteException e) {
     final IOException unwrapped =
         e.unwrapRemoteException(
             FileNotFoundException.class,
             AccessControlException.class,
             QuotaExceededException.class);
     System.err.println(StringUtils.stringifyException(unwrapped));
     return -3;
   } catch (Exception e) {
     System.err.println(
         "With failures, global counters are inaccurate; " + "consider running with -i");
     System.err.println("Copy failed: " + StringUtils.stringifyException(e));
     return -999;
   }
 }
  private static void invoke(MigrationClient migrationClient, Arguments arguments)
      throws APIMigrationException, SQLException {
    // Default operation will migrate all three types of resources
    if (arguments.migrateAll) {
      log.info("Migrating All WSO2 API Manager resources");
      migrationClient.databaseMigration();
      migrationClient.registryResourceMigration();
      migrationClient.fileSystemMigration();
    } else {
      // Only performs database migration
      if (arguments.isDBMigration) {
        log.info("Migrating WSO2 API Manager databases");
        migrationClient.databaseMigration();
      }
      // Only performs registry migration
      if (arguments.isRegistryMigration) {
        log.info("Migrating WSO2 API Manager registry resources");
        migrationClient.registryResourceMigration();
      }
      // Only performs file system migration
      if (arguments.isFileSystemMigration) {
        log.info("Migrating WSO2 API Manager file system resources");
        migrationClient.fileSystemMigration();
      }
    }
    // Old resource cleanup
    if (arguments.cleanupNeeded) {
      migrationClient.cleanOldResources();
      log.info("Old resources cleaned up.");
    }

    if (arguments.isStatMigration) {
      StatDBUtil.initialize();
      migrationClient.statsMigration();
      log.info("Stat migration completed");
    }

    List<String> options = parseOptions(arguments.getOptions());
    if (options != null && options.size() > 0) {
      StatDBUtil.initialize();
      migrationClient.optionalMigration(options);
      log.info("optional migration completed");
    }
  }