Search in sources :

Example 1 with TLogQueryFilter

use of org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter 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);
}
Also used : TLogQueryFilter(org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter) Configuration(org.apache.hadoop.conf.Configuration) TServerName(org.apache.hadoop.hbase.thrift2.generated.TServerName) TLogQueryFilter(org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter) LogQueryFilter(org.apache.hadoop.hbase.client.LogQueryFilter) TOnlineLogRecord(org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord) Assert(org.junit.Assert) ServerName(org.apache.hadoop.hbase.ServerName) TServerName(org.apache.hadoop.hbase.thrift2.generated.TServerName) HBaseThriftTestingUtility(org.apache.hadoop.hbase.thrift.HBaseThriftTestingUtility) Test(org.junit.Test)

Example 2 with TLogQueryFilter

use of org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter in project hbase by apache.

the class ThriftUtilities method getSlowLogQueryFromHBase.

public static TLogQueryFilter getSlowLogQueryFromHBase(LogQueryFilter logQueryFilter) {
    TLogQueryFilter tLogQueryFilter = new TLogQueryFilter();
    tLogQueryFilter.setRegionName(logQueryFilter.getRegionName());
    tLogQueryFilter.setClientAddress(logQueryFilter.getClientAddress());
    tLogQueryFilter.setTableName(logQueryFilter.getTableName());
    tLogQueryFilter.setUserName(logQueryFilter.getUserName());
    tLogQueryFilter.setLimit(logQueryFilter.getLimit());
    TLogType tLogType = gettLogTypeFromHBase(logQueryFilter);
    tLogQueryFilter.setLogType(tLogType);
    TFilterByOperator tFilterByOperator = getTFilterByFromHBase(logQueryFilter);
    tLogQueryFilter.setFilterByOperator(tFilterByOperator);
    return tLogQueryFilter;
}
Also used : TLogQueryFilter(org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter) TLogType(org.apache.hadoop.hbase.thrift2.generated.TLogType) TFilterByOperator(org.apache.hadoop.hbase.thrift2.generated.TFilterByOperator)

Example 3 with TLogQueryFilter

use of org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter in project hbase by apache.

the class ThriftUtilities method getSlowLogQueryFromThrift.

public static LogQueryFilter getSlowLogQueryFromThrift(TLogQueryFilter tLogQueryFilter) {
    LogQueryFilter logQueryFilter = new LogQueryFilter();
    logQueryFilter.setRegionName(tLogQueryFilter.getRegionName());
    logQueryFilter.setClientAddress(tLogQueryFilter.getClientAddress());
    logQueryFilter.setTableName(tLogQueryFilter.getTableName());
    logQueryFilter.setUserName(tLogQueryFilter.getUserName());
    logQueryFilter.setLimit(tLogQueryFilter.getLimit());
    LogQueryFilter.Type type = getLogTypeFromThrift(tLogQueryFilter);
    logQueryFilter.setType(type);
    LogQueryFilter.FilterByOperator filterByOperator = getFilterByFromThrift(tLogQueryFilter);
    logQueryFilter.setFilterByOperator(filterByOperator);
    return logQueryFilter;
}
Also used : TLogQueryFilter(org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter) LogQueryFilter(org.apache.hadoop.hbase.client.LogQueryFilter)

Example 4 with TLogQueryFilter

use of org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter 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);
    }
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) TServerName(org.apache.hadoop.hbase.thrift2.generated.TServerName) TOnlineLogRecord(org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord) OnlineLogRecord(org.apache.hadoop.hbase.client.OnlineLogRecord) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) IOException(java.io.IOException) TLogQueryFilter(org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter) LogQueryFilter(org.apache.hadoop.hbase.client.LogQueryFilter)

Example 5 with TLogQueryFilter

use of org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter 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);
    }
}
Also used : TException(org.apache.thrift.TException) TLogQueryFilter(org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter) TServerName(org.apache.hadoop.hbase.thrift2.generated.TServerName) IOException(java.io.IOException) TOnlineLogRecord(org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord)

Aggregations

TLogQueryFilter (org.apache.hadoop.hbase.thrift2.generated.TLogQueryFilter)5 LogQueryFilter (org.apache.hadoop.hbase.client.LogQueryFilter)3 TOnlineLogRecord (org.apache.hadoop.hbase.thrift2.generated.TOnlineLogRecord)3 TServerName (org.apache.hadoop.hbase.thrift2.generated.TServerName)3 IOException (java.io.IOException)2 ServerName (org.apache.hadoop.hbase.ServerName)2 Configuration (org.apache.hadoop.conf.Configuration)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 OnlineLogRecord (org.apache.hadoop.hbase.client.OnlineLogRecord)1 HBaseThriftTestingUtility (org.apache.hadoop.hbase.thrift.HBaseThriftTestingUtility)1 TFilterByOperator (org.apache.hadoop.hbase.thrift2.generated.TFilterByOperator)1 TLogType (org.apache.hadoop.hbase.thrift2.generated.TLogType)1 TException (org.apache.thrift.TException)1 Assert (org.junit.Assert)1 Test (org.junit.Test)1