use of org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord in project hbase by apache.
the class TestThriftHBaseServiceHandler method testSlowLogResponses.
@Test
public void testSlowLogResponses() throws Exception {
// start a thrift server
HBaseThriftTestingUtility THRIFT_TEST_UTIL = new HBaseThriftTestingUtility();
Configuration configuration = UTIL.getConfiguration();
configuration.setBoolean("hbase.regionserver.slowlog.buffer.enabled", true);
THRIFT_TEST_UTIL.startThriftServer(configuration, ThriftServerType.ONE);
ThriftHBaseServiceHandler thriftHBaseServiceHandler = new ThriftHBaseServiceHandler(configuration, UserProvider.instantiate(configuration));
Collection<ServerName> serverNames = UTIL.getAdmin().getRegionServers();
Set<TServerName> tServerNames = ThriftUtilities.getServerNamesFromHBase(new HashSet<>(serverNames));
List<Boolean> clearedResponses = thriftHBaseServiceHandler.clearSlowLogResponses(tServerNames);
clearedResponses.forEach(Assert::assertTrue);
TLogQueryFilter tLogQueryFilter = new TLogQueryFilter();
tLogQueryFilter.setLimit(15);
Assert.assertEquals(tLogQueryFilter.getFilterByOperator(), TFilterByOperator.OR);
LogQueryFilter logQueryFilter = ThriftUtilities.getSlowLogQueryFromThrift(tLogQueryFilter);
Assert.assertEquals(logQueryFilter.getFilterByOperator(), LogQueryFilter.FilterByOperator.OR);
tLogQueryFilter.setFilterByOperator(TFilterByOperator.AND);
logQueryFilter = ThriftUtilities.getSlowLogQueryFromThrift(tLogQueryFilter);
Assert.assertEquals(logQueryFilter.getFilterByOperator(), LogQueryFilter.FilterByOperator.AND);
List<TOnlineLogRecord> tLogRecords = thriftHBaseServiceHandler.getSlowLogResponses(tServerNames, tLogQueryFilter);
assertEquals(tLogRecords.size(), 0);
}
use of org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord in project hbase by apache.
the class ThriftHBaseServiceHandler method getSlowLogResponses.
@Override
public List<TOnlineLogRecord> getSlowLogResponses(Set<TServerName> tServerNames, TLogQueryFilter tLogQueryFilter) throws TIOError, TException {
try {
Set<ServerName> serverNames = ThriftUtilities.getServerNamesFromThrift(tServerNames);
LogQueryFilter logQueryFilter = ThriftUtilities.getSlowLogQueryFromThrift(tLogQueryFilter);
List<OnlineLogRecord> onlineLogRecords = connectionCache.getAdmin().getSlowLogResponses(serverNames, logQueryFilter);
return ThriftUtilities.getSlowLogRecordsFromHBase(onlineLogRecords);
} catch (IOException e) {
throw getTIOError(e);
}
}
use of org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord in project hbase by apache.
the class ThriftAdmin method getSlowLogResponses.
@Override
public List<OnlineLogRecord> getSlowLogResponses(final Set<ServerName> serverNames, final LogQueryFilter logQueryFilter) throws IOException {
Set<TServerName> tServerNames = ThriftUtilities.getServerNamesFromHBase(serverNames);
TLogQueryFilter tLogQueryFilter = ThriftUtilities.getSlowLogQueryFromHBase(logQueryFilter);
try {
List<TOnlineLogRecord> tOnlineLogRecords = client.getSlowLogResponses(tServerNames, tLogQueryFilter);
return ThriftUtilities.getSlowLogRecordsFromThrift(tOnlineLogRecords);
} catch (TException e) {
throw new IOException(e);
}
}
Aggregations