channel.coordNodeId);
return;
}
ChannelServiceImpl channelService =
ChannelServiceImpl.getChannelService();
DataService dataService = getDataService();
/*
* If a new coordinator has taken over (i.e., 'sendRefresh' is
* true), then all pending events should to be serviced, since
* a 'serviceEventQueue' request may have been missed when the
* former channel coordinator failed and was in the process of
* being reassigned. So, assign the 'serviceAllEvents' flag
* to indicate whether or not all pending events should be
* processed below.
*/
boolean serviceAllEvents = sendRefresh;
if (sendRefresh) {
final BigInteger channelRefId = getChannelRefId();
final String channelName = channel.name;
final Delivery channelDelivery = channel.delivery;
if (logger.isLoggable(Level.FINEST)) {
logger.log(
Level.FINEST, "sending refresh, channel:{0}",
HexDumper.toHexString(channelRefId.toByteArray()));
}
for (final long nodeId : channel.servers) {
channelService.addChannelTask(
channelRefId,
new IoRunnable() {
public void run() throws IOException {
ChannelServer server = getChannelServer(nodeId);
if (server != null) {
server.refresh(channelName, channelRefId,
channelDelivery);
}
} },
nodeId);
}
dataService.markForUpdate(this);
sendRefresh = false;
}
/*
* Process channel events. If the 'serviceAllEvents' flag is
* true, then service all pending events.
*/
int eventsToService = channelService.eventsPerTxn;
ManagedQueue<ChannelEvent> eventQueue = getQueue();
do {
ChannelEvent event = eventQueue.poll();
if (event == null) {
return;
}
logger.log(Level.FINEST, "processing event:{0}", event);
int cost = event.getCost();
if (cost > 0) {
dataService.markForUpdate(this);
writeBufferAvailable += cost;
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST,
"{0} cleared reservation of " +