/**
   * Returns a new {@code ITranslationRuleGen}.
   *
   * @param systemMappingsDoc
   * @param userRelationsDoc
   * @param builtInSchemasDoc
   * @param system
   * @return a new {@code ITranslationGen}
   * @throws XMLParseException
   * @throws ConfigurationException for an illegal combination of options
   */
  public static ITranslationRuleGen newInstance(
      Document systemMappingsDoc,
      Document userRelationsDoc,
      Document builtInSchemasDoc,
      OrchestraSystem system)
      throws XMLParseException {
    boolean outerUnion = Config.getOuterUnion();
    boolean outerJoin = Config.getOuterJoin();
    List<Mapping> systemMappings =
        deserializeVerboseMappings(systemMappingsDoc.getDocumentElement(), system);
    List<RelationContext> userRelations =
        deserializeRelationContexts(userRelationsDoc.getDocumentElement(), system);
    Map<String, Schema> builtInSchemas =
        OrchestraSystem.deserializeBuiltInFunctions(builtInSchemasDoc);
    boolean isBidirectional = system.isBidirectional();

    checkOptions(isBidirectional, outerUnion, outerJoin);
    if (outerUnion) {
      return new OuterUnionTranslationRuleGen(
          systemMappings, userRelations, builtInSchemas, isBidirectional);
    } else if (outerJoin) {
      return new OuterJoinTranslationRuleGen(
          systemMappings, userRelations, builtInSchemas, isBidirectional);
    } else {
      return new DefaultTranslationRuleGen(
          systemMappings, userRelations, builtInSchemas, isBidirectional);
    }
  }
 /**
  * Returns this rule generator.
  *
  * @param systemMappingsDoc
  * @param userRelationsDoc
  * @param builtInSchemasDoc
  * @param system
  * @throws XMLParseException
  */
 TranslationRuleGen(
     Document systemMappingsDoc,
     Document userRelationsDoc,
     Document builtInSchemasDoc,
     OrchestraSystem system)
     throws XMLParseException {
   this.systemMappings =
       deserializeVerboseMappings(systemMappingsDoc.getDocumentElement(), system);
   this.userRelations = deserializeRelationContexts(userRelationsDoc.getDocumentElement(), system);
   this.builtInSchemas = OrchestraSystem.deserializeBuiltInFunctions(builtInSchemasDoc);
   bidirectional = system.isBidirectional();
 }
示例#3
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();
      }
    }
  }
  /**
   * {@inheritDoc}
   *
   * @see edu.upenn.cis.orchestra.AbstractMultiSystemOrchestraTest#shutdownImpl()
   */
  @Override
  protected void shutdownImpl() throws Exception {
    for (ITestFrameWrapper<OrchestraSystem> frame : peerToOrchestraSystemFrame.values()) {
      OrchestraSystem orchestraSystem = frame.getOrchestraController();
      if (orchestraSystem != null) {
        orchestraSystem.getMappingDb().finalize();
        orchestraSystem.reset(false);
        orchestraSystem.getMappingDb().disconnect();
        Assert.assertFalse(
            orchestraSystem.getMappingDb().isConnected(), "Mapping DB did not disconnect.");
        orchestraSystem.disconnect();

        logger.debug("Shutting down Orchestra system.");
      }
    }
  }
示例#5
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();
    }
  }