Package org.hbase.async

Examples of org.hbase.async.HBaseClient$ZKClient


   * @param config An initialized configuration object
   * @since 2.0
   */
  public TSDB(final Config config) {
    this.config = config;
    this.client = new HBaseClient(
        config.getString("tsd.storage.hbase.zk_quorum"),
        config.getString("tsd.storage.hbase.zk_basedir"));
    this.client.setFlushInterval(config.getShort("tsd.storage.flush_interval"));
    table = config.getString("tsd.storage.hbase.data_table").getBytes(CHARSET);
    uidtable = config.getString("tsd.storage.hbase.uid_table").getBytes(CHARSET);
View Full Code Here


 
  /**
   * Mocks classes for testing the storage calls
   */
  private void setupStorage() throws Exception {
    final HBaseClient client = mock(HBaseClient.class);
    final Config config = new Config(false);
    PowerMockito.whenNew(HBaseClient.class)
      .withArguments(anyString(), anyString()).thenReturn(client);
   
    storage = new MockBase(new TSDB(config), client, true, true, true, true);
View Full Code Here

    // through the entire process to create the ID.
    // Then A attempts to go through the process and should discover that the
    // ID has already been assigned.

    uid = new UniqueId(client, table, kind, 3); // Used by client A.
    HBaseClient client_b = mock(HBaseClient.class); // For client B.
    final UniqueId uid_b = new UniqueId(client_b, table, kind, 3);

    final byte[] id = { 0, 0, 5 };
    final byte[] byte_name = { 'f', 'o', 'o' };
    final ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1);
    kvs.add(new KeyValue(byte_name, ID, kind_array, id));

    @SuppressWarnings("unchecked")
    final Deferred<ArrayList<KeyValue>> d = PowerMockito.spy(new Deferred<ArrayList<KeyValue>>());
    when(client.get(anyGet()))
      .thenReturn(d)
      .thenReturn(Deferred.fromResult(kvs));

    final Answer<byte[]> the_race = new Answer<byte[]>() {
      public byte[] answer(final InvocationOnMock unused_invocation) throws Exception {
        // While answering A's first Get, B doest a full getOrCreateId.
        assertArrayEquals(id, uid_b.getOrCreateId("foo"));
        d.callback(null);
        return (byte[]) ((Deferred) d).join();
      }
    };

    // Start the race when answering A's first Get.
    try {
      PowerMockito.doAnswer(the_race).when(d).joinUninterruptibly();
    } catch (Exception e) {
      fail("Should never happen: " + e);
    }

    when(client_b.get(anyGet())) // null => ID doesn't exist.
      .thenReturn(Deferred.<ArrayList<KeyValue>>fromResult(null));
    // Watch this! ______,^ I'm writing C++ in Java!

    when(client_b.atomicIncrement(incrementForRow(MAXID)))
      .thenReturn(Deferred.fromResult(5L));

    when(client_b.compareAndSet(anyPut(), emptyArray()))
      .thenReturn(Deferred.fromResult(true))
      .thenReturn(Deferred.fromResult(true));

    // Now that B is finished, A proceeds and allocates a UID that will be
    // wasted, and creates the reverse mapping, but fails at creating the
View Full Code Here

    if (args.length == 0 || "help".equals(args[0])) {
      System.out.println(usage);
      System.exit(0);
    }

    final HBaseClient client = new HBaseClient("localhost");

    if ("update".equals(args[0])) {
      Deferred<ArrayList<Object>> d = Deferred.group(doList(client));
      try {
        d.join();
      } catch (DeferredGroupException e) {
        LOG.info(e.getCause().getMessage());
      }
    }

    client.shutdown().joinUninterruptibly();
  }
View Full Code Here

TOP

Related Classes of org.hbase.async.HBaseClient$ZKClient

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.