/** * Register channel. * @param channel */ public void registerChannel(CAJChannel channel) { if (canceled) return; synchronized (channels) { if (channels.contains(channel)) return; channels.add(channel); timers[0].installChannel(channel); } }
/** * Notifty about search failure (response timeout). * @param channel channel whose search failed. * @param timerIndex index of timer which tries to search. */ private void searchResponseTimeout(CAJChannel channel, int timerIndex) { int newTimerIndex = Math.min(++timerIndex, timers.length - 1); timers[newTimerIndex].installChannel(channel); }
/** * Move channels to other <code>SearchTimer</code>. * @param destination where to move channels. */ public void moveChannels(SearchTimer destination) { // do not sync this, not necessary and might cause deadlock CAJChannel channel; while ((channel = (CAJChannel)responsePendingChannels.pop()) != null) { if (searchAttempts > 0) searchAttempts--; destination.installChannel(channel); } // bulk move synchronized (requestPendingChannels) { while (!requestPendingChannels.isEmpty()) destination.installChannel((CAJChannel)requestPendingChannels.pop()); } }
/** * Boost searching of a channel. * @param channel channel to boost searching. * @param timerIndex to what timer-index to boost */ private void boostSearching(CAJChannel channel, int timerIndex) { timers[timerIndex].installChannel(channel); }