Пример #1
0
  /**
   * Instantiate and execute the applying patch process
   *
   * @param args
   *     <ul>
   *       <li>Path where we want to apply the patch set
   *       <li>List of patch file path in the proper order
   *     </ul>
   *
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    if (args.length < 2) {
      System.err.println("Usage: dirToPatch patch1 patch2 ...");
      System.err.println(" (1) dirToPatch: base path to patch");
      System.err.println(" (2) patch(x): file path of the patch");
    } else {
      File[] patchList = new File[args.length - 1];

      for (int i = 0; i < patchList.length; i++) {
        patchList[i] = new File(args[i + 1]);

        if (!patchList[i].exists()) {
          System.err.println("File " + args[i + 1] + " does not exist... Please set a valide path");
        }
      }

      File dbTypeFile = new File(FileUtils.createTmpDir(), "dbType.data");
      DBType dbType = new DBType(dbTypeFile.getPath(), "");

      for (int i = 0; i < patchList.length; i++) {
        PatchFile pf = new PatchFile(patchList[i].getPath());
        pf.patch(args[0], dbType);
      }
    }
  }
Пример #2
0
  public static void main(String[] args) throws Exception {
    File dir = FileUtils.createTmpDir();
    File opVectorDir = FileUtils.createTmpDir();
    File attachDir = FileUtils.createTmpDir();
    OpVectorFsImpl opVector = new OpVectorFsImpl(opVectorDir.getAbsolutePath());
    File execDir = FileUtils.createTmpDir();
    File execCompDir = FileUtils.createTmpDir();
    DBType dbType = new DBType(dir.getAbsolutePath() + "/dbType.txt", "");
    WsConnection wsc = new WsConnection("c:/replicaTest/original/.so6/1/so6.properties");
    File[] patchList = wsc.getAppliedPatch().list();
    int index = 1;

    for (int i = 0; i < patchList.length; i++) {
      PatchFile pf = new PatchFile(patchList[i].getAbsolutePath());
      pf.buildOpVector(opVector, attachDir.getAbsolutePath(), null);
    }

    // print history
    Command cmd = null;
    FileWriter fw1 = new FileWriter("c:/originalHist.txt");

    for (ListIterator i = opVector.getCommands(); i.hasNext(); ) {
      cmd = (Command) i.next();
      System.out.println(index);

      if (!(cmd instanceof NeutralCommand)) {
        cmd.execute(execDir.getAbsolutePath(), dbType);
        fw1.write(
            index++
                + "\t"
                + cmd.getClass().getName().substring(cmd.getClass().getName().lastIndexOf(".") + 1)
                + "\t"
                + cmd.getPath()
                + "\t"
                + cmd.getAttachement()
                + "\n");
      }
    }

    fw1.close();

    // compression
    CompressUtil.compressLog(opVector);

    // print new history
    FileWriter fw2 = new FileWriter("c:/compressedHist.txt");
    index = 1;

    for (ListIterator i = opVector.getCommands(); i.hasNext(); ) {
      cmd = (Command) i.next();

      if (!(cmd instanceof NeutralCommand)) {
        System.out.println(index);
        cmd.execute(execCompDir.getAbsolutePath(), dbType);
        fw2.write(
            index++
                + "\t"
                + cmd.getClass().getName().substring(cmd.getClass().getName().lastIndexOf(".") + 1)
                + "\t"
                + cmd.getPath()
                + "\t"
                + cmd.getAttachement()
                + "\n");
      }
    }

    fw2.close();
    System.out.println("Exec dir: " + execDir);
    System.out.println("Exec compression dir: " + execCompDir);
    System.out.println(
        "Compare: "
            + FileUtils.compareDir(execDir.getAbsolutePath(), execCompDir.getAbsolutePath()));
  }