Package com.youtube.vitess.vtgate

Examples of com.youtube.vitess.vtgate.VtGate.begin()


    KeyspaceId kid = testEnv.getAllKeyspaceIds().get(0);
    Query insertQuery = new QueryBuilder(insertSql, testEnv.keyspace, "master")
        .addBindVar(BindVariable.forULong("id", UnsignedLong.valueOf("1")))
        .addBindVar(BindVariable.forULong("keyspace_id", ((UnsignedLong) kid.getId())))
        .addKeyspaceId(kid).build();
    vtgate.begin();
    vtgate.execute(insertQuery);
    vtgate.commit();
    vtgate.begin();
    try {
      vtgate.execute(insertQuery);
View Full Code Here


        .addBindVar(BindVariable.forULong("keyspace_id", ((UnsignedLong) kid.getId())))
        .addKeyspaceId(kid).build();
    vtgate.begin();
    vtgate.execute(insertQuery);
    vtgate.commit();
    vtgate.begin();
    try {
      vtgate.execute(insertQuery);
      Assert.fail("failed to throw exception");
    } catch (IntegrityException e) {
    } finally {
View Full Code Here

    try {
      // Transaction cap is 20
      for (int i = 0; i < 25; i++) {
        VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
        vtgates.add(vtgate);
        vtgate.begin();
        // Run a query to actually begin a transaction with the tablets
        Query query = new QueryBuilder("delete from vtgate_test", testEnv.keyspace, "master")
            .addKeyRange(KeyRange.ALL).build();
        vtgate.execute(query);
      }
View Full Code Here

  @Test
  @Ignore("currently failing as vtgate doesn't set the error")
  public void testStreamingWrites() throws Exception {
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);

    vtgate.begin();
    String insertSql = "insert into vtgate_test " + "(id, name, age, percent, keyspace_id) "
        + "values (:id, :name, :age, :percent, :keyspace_id)";
    KeyspaceId kid = testEnv.getAllKeyspaceIds().get(0);
    Query query = new QueryBuilder(insertSql, testEnv.keyspace, "master")
        .addBindVar(BindVariable.forULong("id", UnsignedLong.valueOf("" + 1)))
View Full Code Here

  @Test
  public void testInts() throws Exception {
    String createTable =
        "create table vtocc_ints(tiny tinyint, tinyu tinyint unsigned, small smallint, smallu smallint unsigned, medium mediumint, mediumu mediumint unsigned, normal int, normalu int unsigned, big bigint, bigu bigint unsigned, year year, primary key(tiny)) comment 'vtocc_nocache'\n" + "";
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    vtgate.begin();
    vtgate.execute(getQuery(createTable));
    vtgate.commit();

    String insertSql =
        "insert into vtocc_ints values(:tiny, :tinyu, :small, :smallu, :medium, :mediumu, :normal, :normalu, :big, :bigu, :year)";
View Full Code Here

        .addBindVar(BindVariable.forLong("big", -9223372036854775808L))
        .addBindVar(BindVariable.forULong("bigu", UnsignedLong.valueOf("18446744073709551615")))
        .addBindVar(BindVariable.forShort("year", (short) 2012))
        .addKeyRange(KeyRange.ALL)
        .build();
    vtgate.begin();
    vtgate.execute(insertQuery);
    vtgate.commit();

    String selectSql = "select * from vtocc_ints where tiny = -128";
    Query selectQuery =
View Full Code Here

  @Test
  public void testFracts() throws Exception {
    String createTable =
        "create table vtocc_fracts(id int, deci decimal(5,2), num numeric(5,2), f float, d double, primary key(id)) comment 'vtocc_nocache'\n" + "";
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    vtgate.begin();
    vtgate.execute(getQuery(createTable));
    vtgate.commit();

    String insertSql = "insert into vtocc_fracts values(:id, :deci, :num, :f, :d)";
    Query insertQuery = new QueryBuilder(insertSql, testEnv.keyspace, "master")
View Full Code Here

        .addBindVar(BindVariable.forDouble("num", 2.99))
        .addBindVar(BindVariable.forFloat("f", 3.99F))
        .addBindVar(BindVariable.forDouble("d", 4.99))
        .addKeyRange(KeyRange.ALL)
        .build();
    vtgate.begin();
    vtgate.execute(insertQuery);
    vtgate.commit();

    String selectSql = "select * from vtocc_fracts where id = 1";
    Query selectQuery =
View Full Code Here

  @Test
  public void testStrings() throws Exception {
    String createTable =
        "create table vtocc_strings(vb varbinary(16), c char(16), vc varchar(16), b binary(4), tb tinyblob, bl blob, ttx tinytext, tx text, en enum('a','b'), s set('a','b'), primary key(vb)) comment 'vtocc_nocache'\n" + "";
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    vtgate.begin();
    vtgate.execute(getQuery(createTable));
    vtgate.commit();

    String insertSql =
        "insert into vtocc_strings values(:vb, :c, :vc, :b, :tb, :bl, :ttx, :tx, :en, :s)";
View Full Code Here

        .addBindVar(BindVariable.forBytes("tx", "h".getBytes()))
        .addBindVar(BindVariable.forString("en", "a"))
        .addBindVar(BindVariable.forString("s", "a,b"))
        .addKeyRange(KeyRange.ALL)
        .build();
    vtgate.begin();
    vtgate.execute(insertQuery);
    vtgate.commit();

    String selectSql = "select * from vtocc_strings where vb = 'a'";
    Query selectQuery =
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.