| 3601 | // while it's splitting a region, which would cause a connection reset). |
| 3602 | final class RetryNSREd implements Callback<Object, Object> { |
| 3603 | public Object call(final Object arg) { |
| 3604 | if (arg instanceof Exception) { |
| 3605 | LOG.warn("Probe " + probe + " failed", (Exception) arg); |
| 3606 | } |
| 3607 | ArrayList<HBaseRpc> removed = got_nsre.remove(region_name); |
| 3608 | if (removed != rpcs && removed != null) { // Should never happen. |
| 3609 | synchronized (removed) { // But just in case... |
| 3610 | synchronized (rpcs) { |
| 3611 | LOG.error("WTF? Impossible! Removed the wrong list of RPCs" |
| 3612 | + " from got_nsre. Was expecting list@" |
| 3613 | + System.identityHashCode(rpcs) + " (size=" + rpcs.size() |
| 3614 | + "), got list@" + System.identityHashCode(removed) |
| 3615 | + " (size=" + removed.size() + ')'); |
| 3616 | } |
| 3617 | for (final HBaseRpc r : removed) { |
| 3618 | if (r != null && r != probe) { |
| 3619 | sendRpcToRegion(r); // We screwed up but let's not lose RPCs. |
| 3620 | } |
| 3621 | } |
| 3622 | removed.clear(); |
| 3623 | } |
| 3624 | } |
| 3625 | removed = null; |
| 3626 | |
| 3627 | synchronized (rpcs) { |
| 3628 | if (LOG.isDebugEnabled()) { |
| 3629 | if (arg instanceof Exception) { |
| 3630 | LOG.debug("Retrying " + rpcs.size() + " RPCs on NSREd region " |
| 3631 | + Bytes.pretty(region_name)); |
| 3632 | } else { |
| 3633 | LOG.debug("Retrying " + rpcs.size() + " RPCs now that the NSRE on " |
| 3634 | + Bytes.pretty(region_name) + " seems to have cleared"); |
| 3635 | } |
| 3636 | } |
| 3637 | final ArrayList<HBaseRpc> rpcs_to_replay = new ArrayList<HBaseRpc>(rpcs); |
| 3638 | rpcs.clear(); // To avoid cyclic RPC chain |
| 3639 | |
| 3640 | final Iterator<HBaseRpc> i = rpcs_to_replay.iterator(); |
| 3641 | if (i.hasNext()) { |
| 3642 | HBaseRpc r = i.next(); |
| 3643 | if (r != probe) { |
| 3644 | LOG.error("WTF? Impossible! Expected first == probe but first=" |
| 3645 | + r + " and probe=" + probe); |
| 3646 | sendRpcToRegion(r); |
| 3647 | } |
| 3648 | while (i.hasNext()) { |
| 3649 | if ((r = i.next()) != null) { |
| 3650 | sendRpcToRegion(r); |
| 3651 | } |
| 3652 | } |
| 3653 | } else { |
| 3654 | // We avoided cyclic RPC chain |
| 3655 | LOG.debug("Empty rpcs array=" + rpcs_to_replay + " found by " + this); |
| 3656 | } |
| 3657 | } |
| 3658 | |
| 3659 | return arg; |
| 3660 | } |