当前位置: 首页>>代码示例>>Java>>正文


Java Hbase类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.thrift.generated.Hbase的典型用法代码示例。如果您正苦于以下问题:Java Hbase类的具体用法?Java Hbase怎么用?Java Hbase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Hbase类属于org.apache.hadoop.hbase.thrift.generated包,在下文中一共展示了Hbase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newInstance

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
public static Hbase.Iface newInstance(Hbase.Iface handler,
                                      ThriftMetrics metrics,
                                      Configuration conf) {
  return (Hbase.Iface) Proxy.newProxyInstance(
      handler.getClass().getClassLoader(),
      new Class[]{Hbase.Iface.class},
      new HbaseHandlerMetricsProxy(handler, metrics, conf));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:9,代码来源:HbaseHandlerMetricsProxy.java

示例2: doTestGetTableRegions

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, regionCount, 1);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, regionCount, 0);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestThriftServer.java

示例3: doTestGetRegionInfo

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
public static void doTestGetRegionInfo(Hbase.Iface handler) throws Exception {
  // Create tableA and add two columns to rowA
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    handler.mutateRow(tableAname, rowAname, getMutations(), null);
    byte[] searchRow = HRegionInfo.createRegionName(
        TableName.valueOf(tableAname.array()), rowAname.array(),
        HConstants.NINES, false);
    TRegionInfo regionInfo = handler.getRegionInfo(ByteBuffer.wrap(searchRow));
    assertTrue(Bytes.toStringBinary(regionInfo.getName()).startsWith(
          Bytes.toStringBinary(tableAname)));
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:17,代码来源:TestThriftServer.java

示例4: setUpBeforeClass

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {

	// binaryProtocol
	if (binaryProtocol) {
		System.out.println("[blockingTransport]");
		ttransport = createTTransport();
		System.out.println("[binaryProtocol]");
		tprotocol = createTBinaryProtocol(ttransport);
	} else {
		System.out.println("[noblockingTransport]");
		ttransport = createTFramedTransport();
		System.out.println("[compactProtocol]");
		tprotocol = createTCompactProtocol(ttransport);
	}
	client = new Hbase.Client(tprotocol);
}
 
开发者ID:mixaceh,项目名称:openyu-commons,代码行数:18,代码来源:HBaseThriftDDLTest.java

示例5: doTestGetTableRegions

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
public static void doTestGetTableRegions(Hbase.Iface handler)
    throws Exception {
  assertEquals(0, handler.getTableNames().size());
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(1, handler.getTableNames().size());
  List<TRegionInfo> regions = handler.getTableRegions(tableAname);
  int regionCount = regions.size();
  assertEquals("empty table should have only 1 region, " +
          "but found " + regionCount, 1, regionCount);
  LOG.info("Region found:" + regions.get(0));
  handler.disableTable(tableAname);
  handler.deleteTable(tableAname);
  regionCount = handler.getTableRegions(tableAname).size();
  assertEquals("non-existing table should have 0 region, " +
          "but found " + regionCount, 0, regionCount);
}
 
开发者ID:apache,项目名称:hbase,代码行数:17,代码来源:TestThriftServer.java

示例6: testExceptionType

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
private void testExceptionType(Hbase.Iface handler, ThriftMetrics metrics,
                               ByteBuffer tTableName, String rowkey,
                               ErrorThrowingGetObserver.ErrorType errorType) throws Exception {
  long preGetCounter = metricsHelper.getCounter("getRow_num_ops", metrics.getSource());
  String exceptionKey = errorType.getMetricName();
  long preExceptionCounter = metricsHelper.checkCounterExists(exceptionKey, metrics.getSource()) ?
      metricsHelper.getCounter(exceptionKey, metrics.getSource()) :
      0;
  Map<ByteBuffer, ByteBuffer> attributes = new HashMap<>();
  attributes.put(asByteBuffer(ErrorThrowingGetObserver.SHOULD_ERROR_ATTRIBUTE),
      asByteBuffer(errorType.name()));
  try {
    List<TRowResult> tRowResult = handler.getRow(tTableName, asByteBuffer(rowkey), attributes);
    fail("Get with error attribute should have thrown an exception");
  } catch (IOError e) {
    LOG.info("Received exception: ", e);
    metricsHelper.assertCounter("getRow_num_ops", preGetCounter + 1, metrics.getSource());
    metricsHelper.assertCounter(exceptionKey, preExceptionCounter + 1, metrics.getSource());
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:21,代码来源:TestThriftServer.java

示例7: talkToThriftServer

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
private void talkToThriftServer(int customHeaderSize) throws Exception {
  THttpClient httpClient = new THttpClient(
      "http://"+ HConstants.LOCALHOST + ":" + port);
  httpClient.open();

  if (customHeaderSize > 0) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < customHeaderSize; i++) {
      sb.append("a");
    }
    httpClient.setCustomHeader("User-Agent", sb.toString());
  }

  try {
    TProtocol prot;
    prot = new TBinaryProtocol(httpClient);
    Hbase.Client client = new Hbase.Client(prot);
    if (!tableCreated){
      TestThriftServer.createTestTables(client);
      tableCreated = true;
    }
    TestThriftServer.checkTableList(client);
  } finally {
    httpClient.close();
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:27,代码来源:TestThriftHttpServer.java

示例8: doTestThriftMetrics

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
/**
 * Tests if the metrics for thrift handler work correctly
 */
public void doTestThriftMetrics() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  ThriftMetrics metrics = getMetrics(conf);
  Hbase.Iface handler = getHandlerForMetricsTest(metrics, conf);
  createTestTables(handler);
  dropTestTables(handler);
  metricsHelper.assertCounter("createTable_num_ops", 2, metrics.getSource());
  metricsHelper.assertCounter("deleteTable_num_ops", 2, metrics.getSource());
  metricsHelper.assertCounter("disableTable_num_ops", 2, metrics.getSource());
  handler.getTableNames(); // This will have an artificial delay.

  // 3 to 6 seconds (to account for potential slowness), measured in nanoseconds
 metricsHelper.assertGaugeGt("getTableNames_avg_time", 3L * 1000 * 1000 * 1000, metrics.getSource());
 metricsHelper.assertGaugeLt("getTableNames_avg_time",6L * 1000 * 1000 * 1000, metrics.getSource());
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:19,代码来源:TestThriftServer.java

示例9: doTestThriftMetrics

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
/**
 * Tests if the metrics for thrift handler work correctly
 */
public void doTestThriftMetrics() throws Exception {
  LOG.info("START doTestThriftMetrics");
  Configuration conf = UTIL.getConfiguration();
  ThriftMetrics metrics = getMetrics(conf);
  Hbase.Iface handler = getHandlerForMetricsTest(metrics, conf);
  int currentCountCreateTable = getCurrentCount("createTable_num_ops", 2, metrics);
  int currentCountDeleteTable = getCurrentCount("deleteTable_num_ops", 2, metrics);
  int currentCountDisableTable = getCurrentCount("disableTable_num_ops", 2, metrics);
  createTestTables(handler);
  dropTestTables(handler);;
  metricsHelper.assertCounter("createTable_num_ops", currentCountCreateTable + 2,
    metrics.getSource());
  metricsHelper.assertCounter("deleteTable_num_ops", currentCountDeleteTable + 2,
    metrics.getSource());
  metricsHelper.assertCounter("disableTable_num_ops", currentCountDisableTable + 2,
    metrics.getSource());
  handler.getTableNames(); // This will have an artificial delay.

  // 3 to 6 seconds (to account for potential slowness), measured in nanoseconds
 try {
   metricsHelper.assertGaugeGt("getTableNames_avg_time", 3L * 1000 * 1000 * 1000, metrics.getSource());
   metricsHelper.assertGaugeLt("getTableNames_avg_time",6L * 1000 * 1000 * 1000, metrics.getSource());
 } catch (AssertionError e) {
   LOG.info("Fix me!  Why does this happen?  A concurrent cluster running?", e);
 }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:30,代码来源:TestThriftServer.java

示例10: createTestTables

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
public static void createTestTables(Hbase.Iface handler) throws Exception {
  // Create/enable/disable/delete tables, ensure methods act correctly
  assertEquals(handler.getTableNames().size(), 0);
  handler.createTable(tableAname, getColumnDescriptors());
  assertEquals(handler.getTableNames().size(), 1);
  assertEquals(handler.getColumnDescriptors(tableAname).size(), 2);
  assertTrue(handler.isTableEnabled(tableAname));
  handler.createTable(tableBname, new ArrayList<ColumnDescriptor>());
  assertEquals(handler.getTableNames().size(), 2);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:11,代码来源:TestThriftServer.java

示例11: dropTestTables

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
public static void dropTestTables(Hbase.Iface handler) throws Exception {
  handler.disableTable(tableBname);
  assertFalse(handler.isTableEnabled(tableBname));
  handler.deleteTable(tableBname);
  assertEquals(handler.getTableNames().size(), 1);
  handler.disableTable(tableAname);
  assertFalse(handler.isTableEnabled(tableAname));
  /* TODO Reenable.
  assertFalse(handler.isTableEnabled(tableAname));
  handler.enableTable(tableAname);
  assertTrue(handler.isTableEnabled(tableAname));
  handler.disableTable(tableAname);*/
  handler.deleteTable(tableAname);
  assertEquals(handler.getTableNames().size(), 0);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:16,代码来源:TestThriftServer.java

示例12: refresh

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
private Hbase.Client refresh(Hbase.Client client, THttpClient httpClient) {
  httpClient.setCustomHeader("doAs", doAsUser);
  if(secure) {
    try {
      httpClient.setCustomHeader("Authorization", generateTicket());
    } catch (GSSException e) {
      e.printStackTrace();
    }
  }
  return client;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:HttpDoAsClient.java

示例13: ThriftServerRunner

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
public ThriftServerRunner(Configuration conf, HBaseHandler handler) {
  this.conf = HBaseConfiguration.create(conf);
  this.listenPort = conf.getInt(PORT_CONF_KEY, DEFAULT_LISTEN_PORT);
  this.metrics = new ThriftMetrics(listenPort, conf, Hbase.Iface.class);
  handler.initMetrics(metrics);
  this.handler = HbaseHandlerMetricsProxy.newInstance(handler, metrics, conf);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:8,代码来源:ThriftServerRunner.java

示例14: doTestThriftMetrics

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
/**
 * Tests if the metrics for thrift handler work correctly
 */
public void doTestThriftMetrics() throws Exception {
  Configuration conf = UTIL.getConfiguration();
  ThriftMetrics metrics = getMetrics(conf);
  Hbase.Iface handler = getHandler(metrics, conf);
  createTestTables(handler);
  dropTestTables(handler);
  verifyMetrics(metrics, "createTable_num_ops", 2);
  verifyMetrics(metrics, "deleteTable_num_ops", 2);
  verifyMetrics(metrics, "disableTable_num_ops", 2);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:14,代码来源:TestThriftServer.java

示例15: dropTestTables

import org.apache.hadoop.hbase.thrift.generated.Hbase; //导入依赖的package包/类
public static void dropTestTables(Hbase.Iface handler) throws Exception {
  handler.disableTable(tableBname);
  assertFalse(handler.isTableEnabled(tableBname));
  handler.deleteTable(tableBname);
  assertEquals(handler.getTableNames().size(), 1);
  handler.disableTable(tableAname);
  /* TODO Reenable.
  assertFalse(handler.isTableEnabled(tableAname));
  handler.enableTable(tableAname);
  assertTrue(handler.isTableEnabled(tableAname));
  handler.disableTable(tableAname);*/
  handler.deleteTable(tableAname);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:14,代码来源:TestThriftServer.java


注:本文中的org.apache.hadoop.hbase.thrift.generated.Hbase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。