Package com.youtube.vitess.vtgate

Examples of com.youtube.vitess.vtgate.Query


        String end = Hex.encodeHexString((byte[]) keyrange.get("End"));
        KeyRange kr = new KeyRange(KeyspaceId.valueOf(start), KeyspaceId.valueOf(end));
        keyranges.add(kr);
      }

      Query q = new QueryBuilder(sql, keyspace, tabletType).setKeyRanges(keyranges)
          .setBindVars(bindVariables).setStreaming(true).build();
      long size = (long) splitObj.get("Size");
      queries.put(q, size);
    }
    return new SplitQueryResponse(queries, error);
View Full Code Here


  @Test
  public void testIntegrityException() throws Exception {
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    String insertSql = "insert into vtgate_test(id, keyspace_id) values (:id, :keyspace_id)";
    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);
View Full Code Here

  @Test
  public void testTimeout() throws ConnectionException, DatabaseException {
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 200);
    // Check timeout error raised for slow query
    Query sleepQuery = new QueryBuilder("select sleep(0.5) from dual", testEnv.keyspace, "master")
        .setKeyspaceIds(testEnv.getAllKeyspaceIds()).build();
    try {
      vtgate.execute(sleepQuery);
      Assert.fail("did not raise timeout exception");
    } catch (ConnectionException e) {
View Full Code Here

      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);
      }
    } catch (DatabaseException e) {
      if (e.getMessage().contains("tx_pool_full")) {
View Full Code Here

  @Test
  public void testShutdownServerWhileStreaming() throws Exception {
    Util.insertRows(testEnv, 1, 2000);
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    String selectSql = "select A.* from vtgate_test A join vtgate_test B";
    Query joinQuery = new QueryBuilder(selectSql, testEnv.keyspace, "master")
        .setKeyspaceIds(testEnv.getAllKeyspaceIds()).setStreaming(true).build();
    Cursor cursor = vtgate.execute(joinQuery);

    int count = 0;
    try {
View Full Code Here

  @Test
  public void testStreamCursorType() throws Exception {
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    String selectSql = "select * from vtgate_test";
    Query allRowsQuery = new QueryBuilder(selectSql, testEnv.keyspace, "master")
        .setKeyspaceIds(testEnv.getAllKeyspaceIds()).setStreaming(true).build();
    Cursor cursor = vtgate.execute(allRowsQuery);
    Assert.assertEquals(StreamCursor.class, cursor.getClass());
    vtgate.close();
  }
View Full Code Here

      Util.insertRowsInShard(testEnv, shardName, rowCount);
    }
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    for (String shardName : testEnv.shardKidMap.keySet()) {
      String selectSql = "select A.* from vtgate_test A join vtgate_test B join vtgate_test C";
      Query query = new QueryBuilder(selectSql, testEnv.keyspace, "master")
          .setKeyspaceIds(testEnv.getKeyspaceIds(shardName)).setStreaming(true).build();
      Cursor cursor = vtgate.execute(query);
      int count = 0;
      while (cursor.hasNext()) {
        cursor.next();
View Full Code Here

    }
    for (String shardName : testEnv.shardKidMap.keySet()) {
      List<KeyspaceId> kids = testEnv.getKeyspaceIds(shardName);
      KeyRange kr = new KeyRange(Collections.min(kids), Collections.max(kids));
      String selectSql = "select A.* from vtgate_test A join vtgate_test B join vtgate_test C";
      Query query = new QueryBuilder(selectSql, testEnv.keyspace, "master").addKeyRange(kr)
          .setStreaming(true).build();
      Cursor cursor = vtgate.execute(query);
      int count = 0;
      while (cursor.hasNext()) {
        cursor.next();
View Full Code Here

    int rowCount = 10;
    for (String shardName : testEnv.shardKidMap.keySet()) {
      Util.insertRowsInShard(testEnv, shardName, rowCount);
    }
    String selectSql = "select A.* from vtgate_test A join vtgate_test B join vtgate_test C";
    Query query = new QueryBuilder(selectSql, testEnv.keyspace, "master")
        .setKeyspaceIds(testEnv.getAllKeyspaceIds()).setStreaming(true).build();
    VtGate vtgate = VtGate.connect("localhost:" + testEnv.port, 0);
    Cursor cursor = vtgate.execute(query);
    int count = 0;
    for (Row row : cursor) {
View Full Code Here

    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)))
        .addBindVar(BindVariable.forString("name", ("name_" + 1)))
        .addBindVar(BindVariable.forULong("keyspace_id", (UnsignedLong) kid.getId()))
        .addKeyspaceId(kid)
        .setStreaming(true)
View Full Code Here

TOP

Related Classes of com.youtube.vitess.vtgate.Query

Copyright © 2018 www.massapicom. 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.