Search in sources :

Example 1 with LockHeartbeatResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos.LockHeartbeatResponse in project hbase by apache.

the class TestLockProcedure method awaitForLocked.

/**
 * Returns immediately if the lock is acquired.
 * @throws TimeoutException if lock couldn't be acquired.
 */
private boolean awaitForLocked(long procId, long timeoutInMs) throws Exception {
    long deadline = EnvironmentEdgeManager.currentTime() + timeoutInMs;
    while (EnvironmentEdgeManager.currentTime() < deadline) {
        LockHeartbeatResponse response = masterRpcService.lockHeartbeat(null, LockHeartbeatRequest.newBuilder().setProcId(procId).build());
        if (response.getLockStatus() == LockHeartbeatResponse.LockStatus.LOCKED) {
            assertEquals(HEARTBEAT_TIMEOUT, response.getTimeoutMs());
            LOG.debug(String.format("Proc id %s acquired lock.", procId));
            return true;
        }
        Thread.sleep(100);
    }
    return false;
}
Also used : LockHeartbeatResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos.LockHeartbeatResponse)

Example 2 with LockHeartbeatResponse

use of org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos.LockHeartbeatResponse in project hbase by apache.

the class TestLockProcedure method sendHeartbeatAndCheckLocked.

private void sendHeartbeatAndCheckLocked(long procId, boolean isLocked) throws ServiceException {
    LockHeartbeatResponse response = masterRpcService.lockHeartbeat(null, LockHeartbeatRequest.newBuilder().setProcId(procId).build());
    if (isLocked) {
        assertEquals(LockHeartbeatResponse.LockStatus.LOCKED, response.getLockStatus());
    } else {
        assertEquals(LockHeartbeatResponse.LockStatus.UNLOCKED, response.getLockStatus());
    }
    LOG.debug(String.format("Proc id %s : %s.", procId, response.getLockStatus()));
}
Also used : LockHeartbeatResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos.LockHeartbeatResponse)

Aggregations

LockHeartbeatResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos.LockHeartbeatResponse)2