Schedules the RPC with the HBaseClient rpc timeout timer with the given timeout interval. If the timeout is set to zero then no timeout is scheduled. If the RPC has already been timed out then we won't allow another attempt. If the timer has shutdown (due to the client shutting down) then we don't d
(final RegionClient region_client)
| 656 | * @throws IllegalStateException if the RPC has already timed out. |
| 657 | */ |
| 658 | void enqueueTimeout(final RegionClient region_client) { |
| 659 | // TODO - it's possible that we may actually retry a timed out RPC in which |
| 660 | // case we want to allow this. |
| 661 | if (has_timedout) { |
| 662 | throw new IllegalStateException("This RPC has already timed out " + this); |
| 663 | } |
| 664 | if (timeout == -1) { |
| 665 | timeout = region_client.getHBaseClient().getDefaultRpcTimeout(); |
| 666 | } |
| 667 | if (timeout > 0) { |
| 668 | this.region_client = region_client; |
| 669 | if (timeout_task == null) { |
| 670 | // we can re-use the task if this RPC is sent to another region server |
| 671 | timeout_task = new TimeoutTask(); |
| 672 | } |
| 673 | try { |
| 674 | if (timeout_handle != null) { |
| 675 | LOG.warn("RPC " + this + " had a previous timeout task"); |
| 676 | } |
| 677 | timeout_handle = region_client.getHBaseClient().getRpcTimeoutTimer() |
| 678 | .newTimeout(timeout_task, timeout, TimeUnit.MILLISECONDS); |
| 679 | } catch (IllegalStateException e) { |
| 680 | // This can happen if the timer fires just before shutdown() |
| 681 | // is called from another thread, and due to how threads get |
| 682 | // scheduled we tried to schedule a timeout after timer.stop(). |
| 683 | // Region clients will handle the RPCs on shutdown so we don't need |
| 684 | // to here. |
| 685 | LOG.warn("Failed to schedule RPC timeout: " + this |
| 686 | + " Ignore this if we're shutting down.", e); |
| 687 | timeout_handle = null; |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | /** @return Whether or not this particular RPC has timed out and should not |
| 693 | * be retried */ |
no test coverage detected