Package com.google.code.hs4j.impl

Examples of com.google.code.hs4j.impl.HSClientImpl


public class HS4JExample {
  public static void main(String[] args) throws Exception {
    // [48, 9, 43, 9, 50, 9, 100, 101, 110, 110, 105, 115, 9, 107, 105, 108,
    // 108, 109, 101, 50, 48, 48, 56, 64, 103, 109, 97, 105, 108, 46, 99,
    // 111, 109, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    HSClient client = new HSClientImpl(new InetSocketAddress(9999), 20);
    final String[] fieldList = { "user_id", "user_name", "user_email",
        "created" };
    System.out.println(client.openIndex(0, "mytest", "test_user", "NAME_MAIL_INDEX",
        fieldList));
    String[] values = { "kevin" };
    ResultSet rs = client.find(0, values);
    while (rs.next()) {
      System.out.println(rs.getString("user_name"));
      System.out.println(rs.getString("user_email"));
      System.out.println(rs.getString("user_id"));
      System.out.println(rs.getTimestamp("created"));
    }
    values = new String[] { "4", "dennis", "test@gmail.com" };
    System.out.println(client.insert(0, values));

    values = new String[] { "dennis" };
    // for (int i = 0; i < 1000; i++) {
    rs = client.find(0, values);
    while (rs.next()) {
      System.out.println(rs.getString("user_name"));
      System.out.println(rs.getString("user_email"));
      System.out.println(rs.getTimestamp("created"));
    }
    // }

    System.out.println(client.delete(0, values, FindOperator.EQ));
    rs = client.find(0, values);
    while (rs.next()) {
      System.out.println(rs.getString("user_name"));
      System.out.println(rs.getString("user_email"));
      // System.out.println(rs.getString("created"));
    }
    client.shutdown();
  }
View Full Code Here


  }

  private static void testHandlerSocket() throws IOException,
      InterruptedException, TimeoutException, HandlerSocketException,
      BrokenBarrierException {
    HSClient hsClient = new HSClientImpl(new InetSocketAddress(9999), 100);
    final String[] columns = { "id", "last_name", "first_name", "duty",
        "cellphone", "housephone", "telephone", "office_fax",
        "home_address", "office_address", "remark" };
    IndexSession session = hsClient.openIndexSession("mytest", "user",
        "PRIMARY", columns);
    CyclicBarrier barrier = new CyclicBarrier(threads + 1);
    String remark = new String(remarkData);
    for (int i = 0; i < threads; i++) {
      HSClientThread mysqlThread = new HSClientThread(barrier, repeats,
          i, session, remark);
      mysqlThread.start();
    }
    long start = System.currentTimeMillis();
    barrier.await();
    barrier.await();
    long end = System.currentTimeMillis();
    long duration = end - start;
    long tps = repeats * threads * 1000 / duration;
    System.out.println("Concurrency " + threads + " threads,repeats="
        + repeats + ",duration=" + duration + "ms,tps=" + tps);

    hsClient.shutdown();
  }
View Full Code Here

        }
      }
    }
    URI url = new URI(props.getProperty("jdbc.url").substring(5));
    this.hostName = url.getHost();
    this.hsClient = new HSClientImpl(this.hostName, 9999);
    this.dbname = url.getPath().substring(1);
    BufferedReader reader = null;
    String createTableSql = null;
    try {
      in = ResourcesUtils.getResourceAsStream("test.sql");
View Full Code Here

TOP

Related Classes of com.google.code.hs4j.impl.HSClientImpl

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.