private static ThriftMetrics getMetrics(Configuration conf) throws Exception { ThriftMetrics m = new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.TWO); m.getSource().init(); //Clear all the metrics return m; }
@Override public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { Object result; long start = now(); try { result = m.invoke(handler, args); } catch (InvocationTargetException e) { metrics.exception(e.getCause()); throw e.getTargetException(); } catch (Exception e) { metrics.exception(e); throw new RuntimeException( "unexpected invocation exception: " + e.getMessage()); } finally { long processTime = now() - start; metrics.incMethodTime(m.getName(), processTime); } return result; }
table = getTable(tableName); if (metrics != null) { metrics.incNumRowKeysInBatchGet(rows.size());
private void updateMetrics(Call result) { if (result == null) { return; } metrics.incTimeInQueue(result.timeInQueue()); metrics.setCallQueueLen(this.size()); }
private static void verifyMetrics(ThriftMetrics metrics, String name, int expectValue) throws Exception { metricsHelper.assertCounter(name, expectValue, metrics.getSource()); }
@Override protected ThriftMetrics createThriftMetrics(Configuration conf) { return new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.TWO); }
addAttributes(delete, attributes); if (metrics != null) { metrics.incNumRowKeysInBatchMutate(mutations.size());
@Override public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { Object result; try { long start = now(); result = m.invoke(handler, args); int processTime = (int)(now() - start); metrics.incMethodTime(m.getName(), processTime); } catch (InvocationTargetException e) { throw e.getTargetException(); } catch (Exception e) { throw new RuntimeException( "unexpected invocation exception: " + e.getMessage()); } return result; } }
@Override protected void beforeExecute(Thread t, Runnable r) { super.beforeExecute(t, r); metrics.incActiveWorkerCount(); }
@Override protected void afterExecute(Runnable r, Throwable t) { metrics.decActiveWorkerCount(); super.afterExecute(r, t); } }
/** * TODO: These counts are supposed to be zero but sometimes they are not, they are equal to the * passed in maybe. Investigate why. My guess is they are set by the test that runs just * previous to this one. Sometimes they are cleared. Sometimes not. */ private int getCurrentCount(final String name, final int maybe, final ThriftMetrics metrics) { int currentCount = 0; try { metricsHelper.assertCounter(name, maybe, metrics.getSource()); LOG.info("Shouldn't this be null? name=" + name + ", equals=" + maybe); currentCount = maybe; } catch (AssertionError e) { // Ignore } return currentCount; }
protected ThriftMetrics createThriftMetrics(Configuration conf) { return new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.ONE); }
private void updateMetrics(Call result) { if (result == null) { return; } metrics.incTimeInQueue(result.timeInQueue()); metrics.setCallQueueLen(this.size()); }
addAttributes(delete, attributes); if (metrics != null) { metrics.incNumRowKeysInBatchMutate(mutations.size());
@Override public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { Object result; try { long start = now(); result = m.invoke(handler, args); int processTime = (int)(now() - start); metrics.incMethodTime(m.getName(), processTime); } catch (InvocationTargetException e) { throw e.getTargetException(); } catch (Exception e) { throw new RuntimeException( "unexpected invocation exception: " + e.getMessage()); } return result; }
@Override protected void beforeExecute(Thread t, Runnable r) { super.beforeExecute(t, r); metrics.incActiveWorkerCount(); }
@Override protected void afterExecute(Runnable r, Throwable t) { metrics.decActiveWorkerCount(); super.afterExecute(r, t); } }
private static ThriftMetrics createMetrics() throws Exception { Configuration conf = UTIL.getConfiguration(); ThriftMetrics m = new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.ONE); m.getSource().init(); return m; }
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 static ThriftMetrics getMetrics(Configuration conf) throws Exception { return new ThriftMetrics(conf, ThriftMetrics.ThriftServerType.ONE); }