Ejemplo n.º 1
0
  public static void runAllmigrateEveryTime(
      OrchestraSystem system, SqlEngine tcd, SqlDb d, List<String> tables) throws Exception {
    tcd.cleanKeepConn();

    Peer p = system.getPeers().iterator().next();
    //		int k = 10; int l = 1;
    for (int k = 1000; k <= 10000; k *= 10) {
      for (int l = k / 10; l <= k / 2; l += k / 10) {
        Config.setWorkloadPrefix(Config.getTestSchemaName() + "-" + k + "i" + l + "d");

        System.out.println("================");
        System.out.println("SCHEMA: " + Config.getWorkloadPrefix());
        System.out.println("================");

        SqlEngine.insTimes = new ArrayList<Long>();
        SqlEngine.delTimes = new ArrayList<Long>();

        setupDb(system, d, tcd, tables);
        runNonIncremental(tcd, p, 5);

        //				for(int m = 0; m < 5; m++){
        //				setupDb(system, d, tcd, tables);
        //				runNonIncremental(tcd, 1);
        //				tcd.cleanKeepConn();
        //				}
        calcAvgTimes();
        tcd.cleanKeepConn();

        SqlEngine.insTimes = new ArrayList<Long>();
        SqlEngine.delTimes = new ArrayList<Long>();

        for (int m = 0; m < 5; m++) {
          setupDb(system, d, tcd, tables);
          runIncremental(tcd, p, 1);
          tcd.cleanKeepConn();
        }
        calcAvgTimes();
      }
    }
  }
Ejemplo n.º 2
0
  public static void main(String[] args) {
    Config.parseCommandLine(args);
    Config.dumpParams(System.out);

    if (Config.getPrepare() && Config.getUnion() && Config.getStratified()) {
      throw new RuntimeException(
          "Current Implementation of stratified deletions"
              + " with prepared statements maps one list of parameters to every query"
              + " and thus doesn't work with union");
    }

    try {
      // NOTE:  a general user will actually call open, importUpdates, etc.
      // but instead we are calling lower-level routines right now, to test.

      RepositorySchemaDAO dao = new FlatFileRepositoryDAO(Config.getSchemaFile());
      OrchestraSystem system = dao.loadAllPeers();
      List<String> tables = SqlEngine.getNamesOfAllTables(system, false, false, true);
      //			List<String> tables = SqlEngine.getNamesOfAllTables(system, true, true, true);

      SqlDb d = new SqlDb(tables, system.getAllSchemas(), system);
      if (Config.getApply()) {
        d.connect();
      }
      SqlEngine tcd =
          new SqlEngine(
              d, // null,
              system);

      Peer p = system.getPeers().iterator().next();

      try {
        if (Config.getApply() && !Config.getBoolean("scalability2"))
          createDatabase(Config.getProperty("schema"), d);

        Debug.println("+++ Basic System Schema +++");
        for (String t : tables) Debug.print(t + "\t");
        Debug.println("");

        Debug.println("+++ Mappings +++");
        List<Mapping> mappings = system.getAllSystemMappings(true);
        for (Mapping s : mappings) Debug.println(s.toString());

        Debug.println("+++ Inverted/Composed Mappings with Provenance Relations +++");
        List<Rule> ruleSet = tcd.computeTranslationRules();

        //				for(RelationContext rel : tcd.getState().getIdbs()){
        //					List<RelationContext> p = tcd.getState().provenanceTablesForRelation(rel);
        //
        //					System.out.println("Provenance tables for " + rel + ": " + p);
        //				}

        for (Rule r : ruleSet) Debug.println(r.toString());

        boolean origApply = true;
        if (Config.getBoolean("scalability2")) {
          origApply = Config.getApply();
          Config.setApply(false);
        }

        if (Config.getApply()) tcd.migrate();

        if (Config.getBoolean("scalability2")) {
          Config.setApply(origApply);
        }

        // DeltaRules ourRules =
        tcd.computeDeltaRules();

        Debug.println("+++ Insertion Rules +++");
        List<DatalogSequence> insRules = tcd.getIncrementalInsertionProgram();
        insRules.get(0).printString();
        insRules.get(1).printString();
        insRules.get(2).printString();

        List<DatalogSequence> delRules = tcd.getIncrementalDeletionProgram();
        Debug.println("+++ Deletion Rules +++");
        delRules.get(0).printString();
        delRules.get(1).printString();
        delRules.get(2).printString();

        List<String> newTables =
            SqlEngine.getNamesOfAllTablesFromDeltas(/*ourRules,*/ system, true, true, true);
        d.setAllTables(newTables);

        if (Config.getBoolean("scalability")) {
          runScalability(tcd, d, p);
        } else if (Config.getBoolean("scalability1")) {
          runScalability1(tcd, d, p);
        } else if (Config.getBoolean("scalability2")) {
          runScalability2(tcd, d, p);
        } else if (Config.getBoolean("nullscycles")) {
          runAllnoMigrateInsOnly(tcd, p);
        } else if (Config.getDebug()) {
          runOnce(tcd, p);
        } else {
          //					runAllmigrateEveryTime(system, tcd, d, tables);
          runAllnoMigrate(tcd, d, p);
        }

        tcd.finalize();
        //				tcd.clean();
        if (Config.getApply()) {
          d.disconnect();
        }

      } catch (Exception e) {
        e.printStackTrace();
        tcd.clean();
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }