mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Revert "9ee129ae6a08935645734ad520bec72bf5f22217"
This reverts "9ee129ae6a08935645734ad520bec72bf5f22217" from #3525, as the solution is not optimal and would cause a single Link to be added in the Map if management server is behind a LB. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
9ee129ae6a
commit
9258c7c3c9
@ -25,7 +25,6 @@ import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.ServerSocketChannel;
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.apache.cloudstack.framework.ca.CAService;
|
||||
@ -37,13 +36,13 @@ public class NioServer extends NioConnection {
|
||||
protected InetSocketAddress _localAddr;
|
||||
private ServerSocketChannel _serverSocket;
|
||||
|
||||
protected Map<String, Link> _links;
|
||||
protected WeakHashMap<InetSocketAddress, Link> _links;
|
||||
|
||||
public NioServer(final String name, final int port, final int workers, final HandlerFactory factory, final CAService caService) {
|
||||
super(name, port, workers, factory);
|
||||
setCAService(caService);
|
||||
_localAddr = null;
|
||||
_links = new WeakHashMap<String, Link>(10240);
|
||||
_links = new WeakHashMap<InetSocketAddress, Link>(1024);
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
@ -76,12 +75,12 @@ public class NioServer extends NioConnection {
|
||||
|
||||
@Override
|
||||
protected void registerLink(final InetSocketAddress addr, final Link link) {
|
||||
_links.put(addr.getAddress().toString(), link);
|
||||
_links.put(addr, link);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void unregisterLink(final InetSocketAddress saddr) {
|
||||
_links.remove(saddr.getAddress().toString());
|
||||
_links.remove(saddr);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +93,7 @@ public class NioServer extends NioConnection {
|
||||
* @return null if not sent. attach object in link if sent.
|
||||
*/
|
||||
public Object send(final InetSocketAddress saddr, final byte[] data) throws ClosedChannelException {
|
||||
final Link link = _links.get(saddr.getAddress().toString());
|
||||
final Link link = _links.get(saddr);
|
||||
if (link == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user