Examples of HBaseClient


Examples of org.hbase.async.HBaseClient

      final String zkquorum = conf.get(HConstants.ZOOKEEPER_QUORUM);
      final String znode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
                                    HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
      synchronized (AsyncTest.class) {
        if (client == null) {
          client = new HBaseClient(zkquorum, znode);
          // Sanity check.
          try {
            client.ensureTableFamilyExists(tableName, FAMILY_NAME).joinUninterruptibly();
          } catch (Exception e) {
            throw new RuntimeException("Missing test table/family?", e);
View Full Code Here

Examples of org.hbase.async.HBaseClient

      sinkCallbackPool = Executors.newCachedThreadPool(new ThreadFactoryBuilder()
        .setNameFormat(this.getName() + " HBase Call Pool").build());
    } else {
      sinkCallbackPool = Executors.newSingleThreadExecutor();
    }
    client = new HBaseClient(zkQuorum, zkBaseDir, sinkCallbackPool);
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicBoolean fail = new AtomicBoolean(false);
    client.ensureTableFamilyExists(
            tableName.getBytes(Charsets.UTF_8), columnFamily).addCallbacks(
            new Callback<Object, Object>() {
View Full Code Here

Examples of org.hbase.async.HBaseClient

    client.shutdown().join();
  }

  /** Ensures the table/family we use for our test exists. */
  private static void preFlightTest(final String[] args) throws Exception {
    final HBaseClient client = Common.getOpt(TestIncrementCoalescing.class,
                                             args);
    try {
      createOrTruncateTable(client, args[0], args[1]);
    } finally {
      client.shutdown().join();
    }
  }
View Full Code Here

Examples of org.hbase.async.HBaseClient

    if (Runtime.getRuntime().maxMemory() < 1992294400L) {
      LOG.error("This test requires at least 2GB of RAM to run.");
      LOG.error("Use JVM_ARGS='-Xmx2g -Xms2g'.");
      System.exit(3);
    }
    final HBaseClient client = Common.getOpt(TestIncrementCoalescing.class,
                                             args);
    final byte[] table = args[0].getBytes();
    final byte[] family = args[1].getBytes();
    try {
      test(client, table, family);
    } finally {
      client.shutdown().join();
    }
  }
View Full Code Here

Examples of org.hbase.async.HBaseClient

    if (args.length > 2) {
      zkquorum = args[2];
    } else {
      zkquorum = "localhost";
    }
    final HBaseClient client;
    if (args.length > 3) {
      return new HBaseClient(zkquorum, args[3]);
    } else {
      return new HBaseClient(zkquorum)// Default znode
    }
  }
View Full Code Here

Examples of org.hbase.async.HBaseClient

    final Cmd cmd = commands.get(args[1]);
    if (cmd == null) {
      fatalUsage("Unknown command: " + args[1], 2);
    }

    final HBaseClient client = new HBaseClient(args[0]);

    try {
      cmd.execute(client, args);
    } catch (Exception e) {
      LOG.error("Unexpected exception caught in main", e);
    }

    System.out.println("Starting shutdown...");
    LOG.debug("Shutdown returned " + client.shutdown().joinUninterruptibly());
    System.out.println("Exiting...");
  }
View Full Code Here

Examples of org.hbase.async.HBaseClient

   * @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

Examples of org.hbase.async.HBaseClient

 
  /**
   * 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

Examples of org.hbase.async.HBaseClient

    // 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

Examples of org.hbase.async.HBaseClient

    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
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.