本文整理汇总了Java中org.apache.hadoop.hbase.thrift2.generated.THBaseService.Iface方法的典型用法代码示例。如果您正苦于以下问题:Java THBaseService.Iface方法的具体用法?Java THBaseService.Iface怎么用?Java THBaseService.Iface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.thrift2.generated.THBaseService
的用法示例。
在下文中一共展示了THBaseService.Iface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMetrics
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
@Test
public void testMetrics() throws Exception {
Configuration conf = UTIL.getConfiguration();
ThriftMetrics metrics = getMetrics(conf);
ThriftHBaseServiceHandler hbaseHandler = createHandler();
THBaseService.Iface handler =
ThriftHBaseServiceHandler.newInstance(hbaseHandler, metrics);
byte[] rowName = "testMetrics".getBytes();
ByteBuffer table = wrap(tableAname);
TGet get = new TGet(wrap(rowName));
assertFalse(handler.exists(table, get));
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));
columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname)));
TPut put = new TPut(wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
assertTrue(handler.exists(table, get));
metricsHelper.assertCounter("put_num_ops", 1, metrics.getSource());
metricsHelper.assertCounter( "exists_num_ops", 2, metrics.getSource());
}
示例2: testMetrics
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
@Test
public void testMetrics() throws Exception {
Configuration conf = UTIL.getConfiguration();
ThriftMetrics metrics = getMetrics(conf);
THBaseService.Iface handler =
ThriftHBaseServiceHandler.newInstance(conf, metrics);
byte[] rowName = "testMetrics".getBytes();
ByteBuffer table = wrap(tableAname);
TGet get = new TGet(wrap(rowName));
assertFalse(handler.exists(table, get));
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));
columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname)));
TPut put = new TPut(wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
assertTrue(handler.exists(table, get));
logMetrics(metrics);
verifyMetrics(metrics, "put_num_ops", 1);
verifyMetrics(metrics, "exists_num_ops", 2);
}
示例3: testMetrics
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
@Test
public void testMetrics() throws Exception {
Configuration conf = UTIL.getConfiguration();
ThriftMetrics metrics = getMetrics(conf);
THBaseService.Iface handler =
ThriftHBaseServiceHandler.newInstance(conf, metrics);
byte[] rowName = "testMetrics".getBytes();
ByteBuffer table = wrap(tableAname);
TGet get = new TGet(wrap(rowName));
assertFalse(handler.exists(table, get));
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));
columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname)));
TPut put = new TPut(wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
assertTrue(handler.exists(table, get));
metricsHelper.assertCounter("put_num_ops", 1, metrics.getSource());
metricsHelper.assertCounter( "exists_num_ops", 2, metrics.getSource());
}
示例4: testMetrics
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
@Test
public void testMetrics() throws Exception {
Configuration conf = UTIL.getConfiguration();
ThriftMetrics metrics = getMetrics(conf);
ThriftHBaseServiceHandler hbaseHandler = createHandler();
THBaseService.Iface handler =
ThriftHBaseServiceHandler.newInstance(hbaseHandler, metrics);
byte[] rowName = Bytes.toBytes("testMetrics");
ByteBuffer table = wrap(tableAname);
TGet get = new TGet(wrap(rowName));
assertFalse(handler.exists(table, get));
List<TColumnValue> columnValues = new ArrayList<>(2);
columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));
columnValues.add(new TColumnValue(wrap(familyBname), wrap(qualifierBname), wrap(valueBname)));
TPut put = new TPut(wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
assertTrue(handler.exists(table, get));
metricsHelper.assertCounter("put_num_ops", 1, metrics.getSource());
metricsHelper.assertCounter("exists_num_ops", 2, metrics.getSource());
}
示例5: testExceptionType
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
private void testExceptionType(THBaseService.Iface handler, ThriftMetrics metrics,
ByteBuffer tTableName, byte[] rowkey, ErrorThrowingGetObserver.ErrorType errorType) {
long preGetCounter = metricsHelper.getCounter("get_num_ops", metrics.getSource());
String exceptionKey = errorType.getMetricName();
long preExceptionCounter = metricsHelper.checkCounterExists(exceptionKey, metrics.getSource()) ?
metricsHelper.getCounter(exceptionKey, metrics.getSource()) :
0;
TGet tGet = new TGet(wrap(rowkey));
Map<ByteBuffer, ByteBuffer> attributes = new HashMap<>();
attributes.put(wrap(Bytes.toBytes(ErrorThrowingGetObserver.SHOULD_ERROR_ATTRIBUTE)),
wrap(Bytes.toBytes(errorType.name())));
tGet.setAttributes(attributes);
try {
TResult tResult = handler.get(tTableName, tGet);
fail("Get with error attribute should have thrown an exception");
} catch (TException e) {
LOG.info("Received exception: ", e);
metricsHelper.assertCounter("get_num_ops", preGetCounter + 1, metrics.getSource());
metricsHelper.assertCounter(exceptionKey, preExceptionCounter + 1, metrics.getSource());
}
}
示例6: newInstance
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
public static THBaseService.Iface newInstance(
Configuration conf, ThriftMetrics metrics) {
THBaseService.Iface handler = new ThriftHBaseServiceHandler(conf);
return (THBaseService.Iface) Proxy.newProxyInstance(
handler.getClass().getClassLoader(),
new Class[]{THBaseService.Iface.class},
new THBaseServiceMetricsProxy(handler, metrics));
}
示例7: testMetrics
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
@Test
public void testMetrics() throws Exception {
Configuration conf = UTIL.getConfiguration();
ThriftMetrics metrics = getMetrics(conf);
THBaseService.Iface handler =
ThriftHBaseServiceHandler.newInstance(conf, metrics);
byte[] rowName = "testMetrics".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
TGet get = new TGet(ByteBuffer.wrap(rowName));
assertFalse(handler.exists(table, get));
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname),
ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname)));
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyBname),
ByteBuffer.wrap(qualifierBname),
ByteBuffer.wrap(valueBname)));
TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
assertTrue(handler.exists(table, get));
logMetrics(metrics);
verifyMetrics(metrics, "put_num_ops", 1);
verifyMetrics(metrics, "exists_num_ops", 2);
}
示例8: testMetrics
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
@Test
public void testMetrics() throws Exception {
Configuration conf = UTIL.getConfiguration();
ThriftMetrics metrics = getMetrics(conf);
THBaseService.Iface handler =
ThriftHBaseServiceHandler.newInstance(conf, metrics);
byte[] rowName = "testMetrics".getBytes();
ByteBuffer table = ByteBuffer.wrap(tableAname);
TGet get = new TGet(ByteBuffer.wrap(rowName));
assertFalse(handler.exists(table, get));
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyAname),
ByteBuffer.wrap(qualifierAname),
ByteBuffer.wrap(valueAname)));
columnValues.add(new TColumnValue(ByteBuffer.wrap(familyBname),
ByteBuffer.wrap(qualifierBname),
ByteBuffer.wrap(valueBname)));
TPut put = new TPut(ByteBuffer.wrap(rowName), columnValues);
put.setColumnValues(columnValues);
handler.put(table, put);
assertTrue(handler.exists(table, get));
metricsHelper.assertCounter("put_num_ops", 1, metrics.getSource());
metricsHelper.assertCounter( "exists_num_ops", 2, metrics.getSource());
}
示例9: newInstance
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
public static THBaseService.Iface newInstance(
THBaseService.Iface handler, ThriftMetrics metrics) {
return (THBaseService.Iface) Proxy.newProxyInstance(handler.getClass().getClassLoader(),
new Class[] { THBaseService.Iface.class }, new THBaseServiceMetricsProxy(handler, metrics));
}
示例10: THBaseServiceMetricsProxy
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
private THBaseServiceMetricsProxy(THBaseService.Iface handler, ThriftMetrics metrics) {
this.handler = handler;
this.metrics = metrics;
}
示例11: newInstance
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
public static THBaseService.Iface newInstance(Configuration conf, ThriftMetrics metrics) {
THBaseService.Iface handler = new ThriftHBaseServiceHandler(conf);
return (THBaseService.Iface) Proxy.newProxyInstance(handler.getClass().getClassLoader(),
new Class[] { THBaseService.Iface.class }, new THBaseServiceMetricsProxy(handler, metrics));
}
示例12: getMetrics
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
private static ThriftMetrics getMetrics(Configuration conf) throws Exception {
setupMetricsContext();
return new ThriftMetrics(Integer.parseInt(ThriftServer.DEFAULT_LISTEN_PORT),
conf, THBaseService.Iface.class);
}
示例13: testMetricsWithException
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
@Test
public void testMetricsWithException() throws Exception {
byte[] rowkey = Bytes.toBytes("row1");
byte[] family = Bytes.toBytes("f");
byte[] col = Bytes.toBytes("c");
// create a table which will throw exceptions for requests
TableName tableName = TableName.valueOf(name.getMethodName());
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
tableDesc.addCoprocessor(ErrorThrowingGetObserver.class.getName());
tableDesc.addFamily(new HColumnDescriptor(family));
Table table = UTIL.createTable(tableDesc, null);
table.put(new Put(rowkey).addColumn(family, col, Bytes.toBytes("val1")));
ThriftHBaseServiceHandler hbaseHandler = createHandler();
ThriftMetrics metrics = getMetrics(UTIL.getConfiguration());
THBaseService.Iface handler =
ThriftHBaseServiceHandler.newInstance(hbaseHandler, metrics);
ByteBuffer tTableName = wrap(tableName.getName());
// check metrics increment with a successful get
long preGetCounter = metricsHelper.checkCounterExists("get_num_ops", metrics.getSource()) ?
metricsHelper.getCounter("get_num_ops", metrics.getSource()) :
0;
TGet tGet = new TGet(wrap(rowkey));
TResult tResult = handler.get(tTableName, tGet);
List<TColumnValue> expectedColumnValues = Lists.newArrayList(
new TColumnValue(wrap(family), wrap(col), wrap(Bytes.toBytes("val1")))
);
assertArrayEquals(rowkey, tResult.getRow());
List<TColumnValue> returnedColumnValues = tResult.getColumnValues();
assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
metricsHelper.assertCounter("get_num_ops", preGetCounter + 1, metrics.getSource());
// check metrics increment when the get throws each exception type
for (ErrorThrowingGetObserver.ErrorType type : ErrorThrowingGetObserver.ErrorType.values()) {
testExceptionType(handler, metrics, tTableName, rowkey, type);
}
}
示例14: testMetricsPrecision
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
/**
* See HBASE-17611
*
* Latency metrics were capped at ~ 2 seconds due to the use of an int variable to capture the
* duration.
*/
@Test
public void testMetricsPrecision() throws Exception {
byte[] rowkey = Bytes.toBytes("row1");
byte[] family = Bytes.toBytes("f");
byte[] col = Bytes.toBytes("c");
// create a table which will throw exceptions for requests
TableName tableName = TableName.valueOf("testMetricsPrecision");
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
tableDesc.addCoprocessor(DelayingRegionObserver.class.getName());
tableDesc.addFamily(new HColumnDescriptor(family));
Table table = null;
try {
table = UTIL.createTable(tableDesc, null);
table.put(new Put(rowkey).addColumn(family, col, Bytes.toBytes("val1")));
ThriftHBaseServiceHandler hbaseHandler = createHandler();
ThriftMetrics metrics = getMetrics(UTIL.getConfiguration());
THBaseService.Iface handler =
ThriftHBaseServiceHandler.newInstance(hbaseHandler, metrics);
ByteBuffer tTableName = wrap(tableName.getName());
// check metrics latency with a successful get
TGet tGet = new TGet(wrap(rowkey));
TResult tResult = handler.get(tTableName, tGet);
List<TColumnValue> expectedColumnValues = Lists.newArrayList(
new TColumnValue(wrap(family), wrap(col), wrap(Bytes.toBytes("val1")))
);
assertArrayEquals(rowkey, tResult.getRow());
List<TColumnValue> returnedColumnValues = tResult.getColumnValues();
assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
metricsHelper.assertGaugeGt("get_max", 3000L, metrics.getSource());
} finally {
if (table != null) {
try {
table.close();
} catch (IOException ignored) {
}
UTIL.deleteTable(tableName);
}
}
}
示例15: THBaseServiceMetricsProxy
import org.apache.hadoop.hbase.thrift2.generated.THBaseService; //导入方法依赖的package包/类
private THBaseServiceMetricsProxy(
THBaseService.Iface handler, ThriftMetrics metrics) {
this.handler = handler;
this.metrics = metrics;
}