Search in sources :

Example 1 with NamedQueueGetResponse

use of org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse in project hbase by apache.

the class SlowLogQueueService method getNamedQueueRecords.

@Override
public NamedQueueGetResponse getNamedQueueRecords(NamedQueueGetRequest request) {
    if (!isOnlineLogProviderEnabled) {
        return null;
    }
    final AdminProtos.SlowLogResponseRequest slowLogResponseRequest = request.getSlowLogResponseRequest();
    final List<TooSlowLog.SlowLogPayload> slowLogPayloads;
    if (AdminProtos.SlowLogResponseRequest.LogType.LARGE_LOG.equals(slowLogResponseRequest.getLogType())) {
        slowLogPayloads = getLargeLogPayloads(slowLogResponseRequest);
    } else {
        slowLogPayloads = getSlowLogPayloads(slowLogResponseRequest);
    }
    NamedQueueGetResponse response = new NamedQueueGetResponse();
    response.setNamedQueueEvent(RpcLogDetails.SLOW_LOG_EVENT);
    response.setSlowLogPayloads(slowLogPayloads);
    return response;
}
Also used : AdminProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos) NamedQueueGetResponse(org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse)

Example 2 with NamedQueueGetResponse

use of org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse in project hbase by apache.

the class TestSlowLogAccessor method getSlowLogPayloads.

private List<TooSlowLog.SlowLogPayload> getSlowLogPayloads(AdminProtos.SlowLogResponseRequest request) {
    NamedQueueGetRequest namedQueueGetRequest = new NamedQueueGetRequest();
    namedQueueGetRequest.setNamedQueueEvent(RpcLogDetails.SLOW_LOG_EVENT);
    namedQueueGetRequest.setSlowLogResponseRequest(request);
    NamedQueueGetResponse namedQueueGetResponse = namedQueueRecorder.getNamedQueueRecords(namedQueueGetRequest);
    return namedQueueGetResponse.getSlowLogPayloads();
}
Also used : NamedQueueGetResponse(org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse) NamedQueueGetRequest(org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest)

Example 3 with NamedQueueGetResponse

use of org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse in project hbase by apache.

the class TestBalancerRejection method getBalancerRejectionLogEntries.

private List<LogEntry> getBalancerRejectionLogEntries(MasterClusterInfoProvider provider) {
    NamedQueueGetRequest namedQueueGetRequest = new NamedQueueGetRequest();
    namedQueueGetRequest.setNamedQueueEvent(BalancerRejectionDetails.BALANCER_REJECTION_EVENT);
    namedQueueGetRequest.setBalancerRejectionsRequest(MasterProtos.BalancerRejectionsRequest.getDefaultInstance());
    NamedQueueGetResponse namedQueueGetResponse = provider.getNamedQueueRecorder().getNamedQueueRecords(namedQueueGetRequest);
    List<RecentLogs.BalancerRejection> balancerRejections = namedQueueGetResponse.getBalancerRejections();
    MasterProtos.BalancerRejectionsResponse response = MasterProtos.BalancerRejectionsResponse.newBuilder().addAllBalancerRejection(balancerRejections).build();
    List<LogEntry> balancerRejectionRecords = ProtobufUtil.getBalancerRejectionEntries(response);
    return balancerRejectionRecords;
}
Also used : NamedQueueGetResponse(org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse) NamedQueueGetRequest(org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest) LogEntry(org.apache.hadoop.hbase.client.LogEntry) MasterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos)

Example 4 with NamedQueueGetResponse

use of org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse in project hbase by apache.

the class TestBalancerDecision method testBalancerDecisions.

@Test
public void testBalancerDecisions() {
    conf.setBoolean("hbase.master.balancer.decision.buffer.enabled", true);
    MasterServices services = mock(MasterServices.class);
    when(services.getConfiguration()).thenReturn(conf);
    MasterClusterInfoProvider provider = new MasterClusterInfoProvider(services);
    loadBalancer.setClusterInfoProvider(provider);
    loadBalancer.onConfigurationChange(conf);
    float minCost = conf.getFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 0.05f);
    conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", 1.0f);
    try {
        // Test with/without per table balancer.
        boolean[] perTableBalancerConfigs = { true, false };
        for (boolean isByTable : perTableBalancerConfigs) {
            conf.setBoolean(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE, isByTable);
            loadBalancer.onConfigurationChange(conf);
            for (int[] mockCluster : clusterStateMocks) {
                Map<ServerName, List<RegionInfo>> servers = mockClusterServers(mockCluster);
                Map<TableName, Map<ServerName, List<RegionInfo>>> LoadOfAllTable = (Map) mockClusterServersWithTables(servers);
                List<RegionPlan> plans = loadBalancer.balanceCluster(LoadOfAllTable);
                boolean emptyPlans = plans == null || plans.isEmpty();
                Assert.assertTrue(emptyPlans || needsBalanceIdleRegion(mockCluster));
            }
        }
        final NamedQueueGetRequest namedQueueGetRequest = new NamedQueueGetRequest();
        namedQueueGetRequest.setNamedQueueEvent(BalancerDecisionDetails.BALANCER_DECISION_EVENT);
        namedQueueGetRequest.setBalancerDecisionsRequest(MasterProtos.BalancerDecisionsRequest.getDefaultInstance());
        NamedQueueGetResponse namedQueueGetResponse = provider.getNamedQueueRecorder().getNamedQueueRecords(namedQueueGetRequest);
        List<RecentLogs.BalancerDecision> balancerDecisions = namedQueueGetResponse.getBalancerDecisions();
        MasterProtos.BalancerDecisionsResponse response = MasterProtos.BalancerDecisionsResponse.newBuilder().addAllBalancerDecision(balancerDecisions).build();
        List<LogEntry> balancerDecisionRecords = ProtobufUtil.getBalancerDecisionEntries(response);
        Assert.assertTrue(balancerDecisionRecords.size() > 160);
    } finally {
        // reset config
        conf.unset(HConstants.HBASE_MASTER_LOADBALANCE_BYTABLE);
        conf.setFloat("hbase.master.balancer.stochastic.minCostNeedBalance", minCost);
        loadBalancer.onConfigurationChange(conf);
    }
}
Also used : RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) MasterServices(org.apache.hadoop.hbase.master.MasterServices) TableName(org.apache.hadoop.hbase.TableName) RegionPlan(org.apache.hadoop.hbase.master.RegionPlan) ServerName(org.apache.hadoop.hbase.ServerName) List(java.util.List) NamedQueueGetResponse(org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse) Map(java.util.Map) NamedQueueGetRequest(org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest) LogEntry(org.apache.hadoop.hbase.client.LogEntry) MasterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos) Test(org.junit.Test)

Example 5 with NamedQueueGetResponse

use of org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse in project hbase by apache.

the class BalancerDecisionQueueService method getNamedQueueRecords.

@Override
public NamedQueueGetResponse getNamedQueueRecords(NamedQueueGetRequest request) {
    if (!isBalancerDecisionRecording) {
        return null;
    }
    List<RecentLogs.BalancerDecision> balancerDecisions = Arrays.stream(balancerDecisionQueue.toArray(new RecentLogs.BalancerDecision[0])).collect(Collectors.toList());
    // latest records should be displayed first, hence reverse order sorting
    Collections.reverse(balancerDecisions);
    int limit = balancerDecisions.size();
    if (request.getBalancerDecisionsRequest().hasLimit()) {
        limit = Math.min(request.getBalancerDecisionsRequest().getLimit(), balancerDecisions.size());
    }
    // filter limit if provided
    balancerDecisions = balancerDecisions.subList(0, limit);
    final NamedQueueGetResponse namedQueueGetResponse = new NamedQueueGetResponse();
    namedQueueGetResponse.setNamedQueueEvent(BalancerDecisionDetails.BALANCER_DECISION_EVENT);
    namedQueueGetResponse.setBalancerDecisions(balancerDecisions);
    return namedQueueGetResponse;
}
Also used : RecentLogs(org.apache.hadoop.hbase.shaded.protobuf.generated.RecentLogs) BalancerDecision(org.apache.hadoop.hbase.client.BalancerDecision) NamedQueueGetResponse(org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse)

Aggregations

NamedQueueGetResponse (org.apache.hadoop.hbase.namequeues.response.NamedQueueGetResponse)10 NamedQueueGetRequest (org.apache.hadoop.hbase.namequeues.request.NamedQueueGetRequest)7 LogEntry (org.apache.hadoop.hbase.client.LogEntry)2 NamedQueueRecorder (org.apache.hadoop.hbase.namequeues.NamedQueueRecorder)2 MasterProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos)2 RecentLogs (org.apache.hadoop.hbase.shaded.protobuf.generated.RecentLogs)2 List (java.util.List)1 Map (java.util.Map)1 ServerName (org.apache.hadoop.hbase.ServerName)1 TableName (org.apache.hadoop.hbase.TableName)1 BalancerDecision (org.apache.hadoop.hbase.client.BalancerDecision)1 BalancerRejection (org.apache.hadoop.hbase.client.BalancerRejection)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1 MasterServices (org.apache.hadoop.hbase.master.MasterServices)1 RegionPlan (org.apache.hadoop.hbase.master.RegionPlan)1 AdminProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos)1 SlowLogPayload (org.apache.hadoop.hbase.shaded.protobuf.generated.TooSlowLog.SlowLogPayload)1 Test (org.junit.Test)1