Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Update Server.java #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/core/org/apache/hadoop/ipc/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ public void run() {
}
}

void addChannelToQueue(SocketChannel channel) {
newChannels.add(channel);
void addChannelToQueue(SocketChannel channel) throws InterruptedException{
newChannels.put(channel);
readSelector.wakeup();
}

Expand Down Expand Up @@ -608,7 +608,32 @@ void doAccept(SelectionKey key) throws IOException, OutOfMemoryError {
channel.configureBlocking(false);
channel.socket().setTcpNoDelay(tcpNoDelay);
Reader reader = getReader();
reader.addChannelToQueue(channel);
try {
reader.addChannelToQueue(channel);
if (LOG.isDebugEnabled())
LOG.debug("Add connection to queue from " +
NetUtils.getSrcNameFromSocketChannel(channel) +
"; # active connections: " + numConnections +
"; # queued calls: " + callQueue.size());
} catch (RuntimeException e) {
channel.close();
if (LOG.isDebugEnabled())
LOG.debug("Faied to add connection to queue from " +
NetUtils.getSrcNameFromSocketChannel(channel) +
"; # active connections: " + numConnections +
"; # queued calls: " + callQueue.size() +
"; # reader.queueSize " + reader.getNewChannelsSize());
throw e;
} catch (InterruptedException e) {
channel.close();
if (LOG.isDebugEnabled())
LOG.debug("Interrupt to add connection to queue from " +
NetUtils.getSrcNameFromSocketChannel(channel) +
"; # active connections: " + numConnections +
"; # queued calls: " + callQueue.size() +
"; # reader.queueSize " + reader.getNewChannelsSize());
Thread.currentThread().interrupt();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Add connection to queue from "
+ NetUtils.getSrcNameFromSocketChannel(channel)
Expand Down