@Test public void testMetrics() throws Exception { Configuration conf = UTIL.getConfiguration(); ThriftMetrics metrics = getMetrics(conf); ThriftHBaseServiceHandler hbaseHandler = createHandler(); THBaseService.Iface handler = HbaseHandlerMetricsProxy.newInstance(hbaseHandler, metrics, conf); 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()); }
TResult tResult = handler.get(tTableName, tGet);
TResult tResult = handler.get(tTableName, tGet);
0; TGet tGet = new TGet(wrap(rowkey)); TResult tResult = handler.get(tTableName, tGet);
0; TGet tGet = new TGet(wrap(rowkey)); TResult tResult = handler.get(tTableName, tGet);
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()); } }
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()); } }
@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()); }
@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()); }
public checkAndDelete_result getResult(I iface, checkAndDelete_args args) throws org.apache.thrift.TException { checkAndDelete_result result = new checkAndDelete_result(); try { result.success = iface.checkAndDelete(args.table, args.row, args.family, args.qualifier, args.value, args.tdelete); result.setSuccessIsSet(true); } catch (TIOError io) { result.io = io; } return result; } }
public getScannerRows_result getResult(I iface, getScannerRows_args args) throws org.apache.thrift.TException { getScannerRows_result result = new getScannerRows_result(); try { result.success = iface.getScannerRows(args.scannerId, args.numRows); } catch (TIOError io) { result.io = io; } catch (TIllegalArgument ia) { result.ia = ia; } return result; } }
public get_result getResult(I iface, get_args args) throws org.apache.thrift.TException { get_result result = new get_result(); try { result.success = iface.get(args.table, args.tget); } catch (TIOError io) { result.io = io; } return result; } }
protected getScannerRows_result getResult(I iface, getScannerRows_args args) throws org.apache.thrift.TException { getScannerRows_result result = new getScannerRows_result(); try { result.success = iface.getScannerRows(args.scannerId, args.numRows); } catch (TIOError io) { result.io = io; } catch (TIllegalArgument ia) { result.ia = ia; } return result; } }
protected checkAndDelete_result getResult(I iface, checkAndDelete_args args) throws org.apache.thrift.TException { checkAndDelete_result result = new checkAndDelete_result(); try { result.success = iface.checkAndDelete(args.table, args.row, args.family, args.qualifier, args.value, args.deleteSingle); result.setSuccessIsSet(true); } catch (TIOError io) { result.io = io; } return result; } }
protected closeScanner_result getResult(I iface, closeScanner_args args) throws org.apache.thrift.TException { closeScanner_result result = new closeScanner_result(); try { iface.closeScanner(args.scannerId); } catch (TIOError io) { result.io = io; } catch (TIllegalArgument ia) { result.ia = ia; } return result; } }
protected put_result getResult(I iface, put_args args) throws org.apache.thrift.TException { put_result result = new put_result(); try { iface.put(args.table, args.put); } catch (TIOError io) { result.io = io; } return result; } }
protected getMultiple_result getResult(I iface, getMultiple_args args) throws org.apache.thrift.TException { getMultiple_result result = new getMultiple_result(); try { result.success = iface.getMultiple(args.table, args.gets); } catch (TIOError io) { result.io = io; } return result; } }
public deleteSingle_result getResult(I iface, deleteSingle_args args) throws org.apache.thrift.TException { deleteSingle_result result = new deleteSingle_result(); try { iface.deleteSingle(args.table, args.tdelete); } catch (TIOError io) { result.io = io; } return result; } }