コード例 #1
0
  /**
   * Verify that we properly ignore operations on schemas including those with wildcard
   * substitutions.
   */
  public void testSchemasIgnored() throws ReplicatorException, InterruptedException {
    // Configure the filter to allow databases including wild cards.
    ReplicateFilter rf = new ReplicateFilter();
    rf.setTungstenSchema("tungsten_foo");
    rf.setIgnore("foo,foobar?,bar*");
    filterHelper.setFilter(rf);

    // Confirm that the following commands are ignored if the default
    // database is foo.
    verifyStmtIgnore(filterHelper, 0, "bar", "create database foo");
    verifyStmtIgnore(filterHelper, 1, "foo", "drop database bar");
    verifyStmtIgnore(filterHelper, 2, "foo", "delete from bar2.test where id=2");
    verifyStmtIgnore(filterHelper, 3, "foo", "insert into foobar1.x1 values(1,2,3)");
    verifyStmtIgnore(filterHelper, 4, "foo", "update test_tab set age=32 where id=1");

    // Just for calibration ensure we accept a non-matching schema.
    verifyStmtAccept(filterHelper, 5, "foo", "insert into test.tab values(52,1)");

    // All done.
    filterHelper.done();
  }
コード例 #2
0
  /** Verify that we always accept the Tungsten catalog even if it is explicitly ignored. */
  public void testTungstenCatalogAccept() throws ReplicatorException, InterruptedException {
    // Configure the filter to allow databases including wild cards.
    ReplicateFilter rf = new ReplicateFilter();
    rf.setTungstenSchema("tungsten_foo");
    rf.setIgnore("tungsten_foo");
    filterHelper.setFilter(rf);

    // Confirm that the following commands are accepted.
    verifyStmtAccept(
        filterHelper, 0, "bar", "delete from tungsten_foo.trep_commit_seqno where task_id=9");
    verifyRowAccept(
        filterHelper,
        1,
        "tungsten_foo",
        "trep_commit_seqno",
        new String[] {"task_id"},
        new Object[] {0});

    // All done.
    filterHelper.done();
  }
コード例 #3
0
  /** Verify that we handle cases where a subset of databases and/or tables is ignored. */
  public void testSchemasIgnoreSubset() throws ReplicatorException, InterruptedException {
    // Configure the filter to allow databases including wild cards.
    ReplicateFilter rf = new ReplicateFilter();
    rf.setTungstenSchema("tungsten_foo");
    rf.setDo("foobar?,bar*,foo");
    rf.setIgnore("foo.test,foobar2,bar23*");
    filterHelper.setFilter(rf);

    // Confirm that the following commands are accepted if the default
    // database is foo.
    verifyStmtAccept(filterHelper, 0, null, "create database foobar1");
    verifyStmtAccept(filterHelper, 1, "foo", "drop table foo.test2");
    verifyStmtAccept(filterHelper, 2, "foo", "delete from bar2.test where id=2");

    // Confirm that we ignore subset values.
    verifyStmtIgnore(filterHelper, 3, "foo", "delete from foo.test where id=2");
    verifyStmtIgnore(filterHelper, 4, "foo", "create table foobar2.foobar1 (id int)");
    verifyStmtIgnore(filterHelper, 5, "foo", "drop database bar234");

    // All done.
    filterHelper.done();
  }
コード例 #4
0
  /** Verify that we accept and ignore databases appropriately when using row updates. */
  public void testRowHandling() throws ReplicatorException, InterruptedException {
    // Configure the filter to allow databases including wild cards.
    ReplicateFilter rf = new ReplicateFilter();
    rf.setTungstenSchema("tungsten_foo");
    rf.setDo("foobar?,bar*,foo");
    rf.setIgnore("foo.test,foobar2,bar23*");
    filterHelper.setFilter(rf);

    // Verify accepted events.
    String names[] = {"id"};
    Long values[] = {new Long(99)};
    verifyRowAccept(filterHelper, 0, "foobar1", "foobar2", names, values);
    verifyRowAccept(filterHelper, 1, "bar2", "foo", names, values);
    verifyRowAccept(filterHelper, 2, "foo", "test2", names, values);

    // Verify ignored events.
    verifyRowIgnore(filterHelper, 3, "foo", "test", names, values);
    verifyRowIgnore(filterHelper, 4, "foobar2", "foobar1", names, values);
    verifyRowIgnore(filterHelper, 5, "bar234", "foobar1", names, values);

    // All done.
    filterHelper.done();
  }